From c912e4c787ae01a34fa48576e099fcb5950dd828 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 26 Jun 2014 01:45:07 +0000 Subject: CodeGen: Improve warnings about uninstrumented files when profiling Improve the warning when building with -fprofile-instr-use and a file appears not to have been profiled at all. This keys on whether a function is defined in the main file or not to avoid false negatives when one includes a header with functions that have been profiled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211760 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Profile/Inputs/c-unprofiled.proftext | 10 ++++++++++ test/Profile/Inputs/profiled_header.h | 3 +++ test/Profile/c-unprofiled.c | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 test/Profile/Inputs/c-unprofiled.proftext create mode 100644 test/Profile/Inputs/profiled_header.h create mode 100644 test/Profile/c-unprofiled.c (limited to 'test/Profile') diff --git a/test/Profile/Inputs/c-unprofiled.proftext b/test/Profile/Inputs/c-unprofiled.proftext new file mode 100644 index 0000000000..d2ef7ae301 --- /dev/null +++ b/test/Profile/Inputs/c-unprofiled.proftext @@ -0,0 +1,10 @@ +function_in_header +10 +2 +1 +0 + +main +0 +1 +1 diff --git a/test/Profile/Inputs/profiled_header.h b/test/Profile/Inputs/profiled_header.h new file mode 100644 index 0000000000..fa649d4b59 --- /dev/null +++ b/test/Profile/Inputs/profiled_header.h @@ -0,0 +1,3 @@ +void function_in_header(int i) { + if (i) {} +} diff --git a/test/Profile/c-unprofiled.c b/test/Profile/c-unprofiled.c new file mode 100644 index 0000000000..275cd2d145 --- /dev/null +++ b/test/Profile/c-unprofiled.c @@ -0,0 +1,26 @@ +// Test that unprofiled files are recognized. Here, we have two functions in the +// profile, main() and function_in_header, but we use the profile on a file that +// has the profile-less some_unprofiled_function so that the only profiled code +// in #included in a header. + +// FIXME: It would be nice to use -verify here instead of FileCheck, but -verify +// doesn't play well with warnings that have no line number. + +// RUN: llvm-profdata merge %S/Inputs/c-unprofiled.proftext -o %t.profdata +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-unprofiled.c -I %S/Inputs/ %s -o /dev/null -emit-llvm -fprofile-instr-use=%t.profdata -Wprofile-instr-unprofiled 2>&1 | FileCheck %s + +// CHECK: warning: no profile data available for file "c-unprofiled.c" + +#include "profiled_header.h" + +#ifdef GENERATE_OUTDATED_DATA +int main(int argc, const char *argv[]) { + function_in_header(0); + return 0; +} +#else +void some_unprofiled_function(int i) { + if (i) + function_in_header(i); +} +#endif -- cgit v1.2.3