summaryrefslogtreecommitdiffstats
path: root/clang/test/Profile
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-06-26 01:45:07 +0000
committerJustin Bogner <mail@justinbogner.com>2014-06-26 01:45:07 +0000
commit40b8ba1496e54066b69c181b40d37ec1a823862b (patch)
tree0803ea1ed0709c089a204898ea6fafbd4c3a1ec1 /clang/test/Profile
parent2710d01ce2394637070472f0355138f162315ec1 (diff)
downloadbcm5719-llvm-40b8ba1496e54066b69c181b40d37ec1a823862b.tar.gz
bcm5719-llvm-40b8ba1496e54066b69c181b40d37ec1a823862b.zip
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. llvm-svn: 211760
Diffstat (limited to 'clang/test/Profile')
-rw-r--r--clang/test/Profile/Inputs/c-unprofiled.proftext10
-rw-r--r--clang/test/Profile/Inputs/profiled_header.h3
-rw-r--r--clang/test/Profile/c-unprofiled.c26
3 files changed, 39 insertions, 0 deletions
diff --git a/clang/test/Profile/Inputs/c-unprofiled.proftext b/clang/test/Profile/Inputs/c-unprofiled.proftext
new file mode 100644
index 00000000000..d2ef7ae301d
--- /dev/null
+++ b/clang/test/Profile/Inputs/c-unprofiled.proftext
@@ -0,0 +1,10 @@
+function_in_header
+10
+2
+1
+0
+
+main
+0
+1
+1
diff --git a/clang/test/Profile/Inputs/profiled_header.h b/clang/test/Profile/Inputs/profiled_header.h
new file mode 100644
index 00000000000..fa649d4b599
--- /dev/null
+++ b/clang/test/Profile/Inputs/profiled_header.h
@@ -0,0 +1,3 @@
+void function_in_header(int i) {
+ if (i) {}
+}
diff --git a/clang/test/Profile/c-unprofiled.c b/clang/test/Profile/c-unprofiled.c
new file mode 100644
index 00000000000..275cd2d1458
--- /dev/null
+++ b/clang/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
OpenPOWER on IntegriCloud