summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2016-09-13 04:32:40 +0000
committerAdam Nemet <anemet@apple.com>2016-09-13 04:32:40 +0000
commit1eea3e577d2fce03d8b2d697786591a982f10d15 (patch)
tree455e66fa3d5187d66a5fa450ed0367d1a763c732 /clang/test
parentd97d5a2cee684e6e03006bb87a58a9acefe36375 (diff)
downloadbcm5719-llvm-1eea3e577d2fce03d8b2d697786591a982f10d15.tar.gz
bcm5719-llvm-1eea3e577d2fce03d8b2d697786591a982f10d15.zip
Reapply r281276 with passing -emit-llvm in one of the tests
Original commit message: Add -fdiagnostics-show-hotness Summary: I've recently added the ability for optimization remarks to include the hotness of the corresponding code region. This uses PGO and allows filtering of the optimization remarks by relevance. The idea was first discussed here: http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334 The general goal is to produce a YAML file with the remarks. Then, an external tool could dynamically filter these by hotness and perhaps by other things. That said it makes sense to also expose this at the more basic level where we just include the hotness info with each optimization remark. For example, in D22694, the clang flag was pretty useful to measure the overhead of the additional analyses required to include hotness. (Without the flag we don't even run the analyses.) For the record, Hal has already expressed support for the idea of this patch on IRC. Differential Revision: https://reviews.llvm.org/D23284 llvm-svn: 281293
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Frontend/Inputs/optimization-remark-with-hotness.proftext25
-rw-r--r--clang/test/Frontend/optimization-remark-with-hotness.c45
2 files changed, 70 insertions, 0 deletions
diff --git a/clang/test/Frontend/Inputs/optimization-remark-with-hotness.proftext b/clang/test/Frontend/Inputs/optimization-remark-with-hotness.proftext
new file mode 100644
index 00000000000..af111d6d06b
--- /dev/null
+++ b/clang/test/Frontend/Inputs/optimization-remark-with-hotness.proftext
@@ -0,0 +1,25 @@
+foo
+# Func Hash:
+0
+# Num Counters:
+1
+# Counter Values:
+30
+
+bar
+# Func Hash:
+0
+# Num Counters:
+1
+# Counter Values:
+30
+
+main
+# Func Hash:
+4
+# Num Counters:
+2
+# Counter Values:
+1
+30
+
diff --git a/clang/test/Frontend/optimization-remark-with-hotness.c b/clang/test/Frontend/optimization-remark-with-hotness.c
new file mode 100644
index 00000000000..4c27e866f4c
--- /dev/null
+++ b/clang/test/Frontend/optimization-remark-with-hotness.c
@@ -0,0 +1,45 @@
+// RUN: llvm-profdata merge \
+// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \
+// RUN: -o %t.profdata
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness -verify
+// The clang version of the previous test.
+// RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
+// RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness -Xclang -verify
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
+// RUN: -check-prefix=HOTNESS_OFF %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -Rpass=inline -Rpass-analysis=inline -fdiagnostics-show-hotness 2>&1 \
+// RUN: | FileCheck -check-prefix=NO_PGO %s
+
+int foo(int x, int y) __attribute__((always_inline));
+int foo(int x, int y) { return x + y; }
+
+int sum = 0;
+
+void bar(int x) {
+ // HOTNESS_OFF: foo inlined into bar
+ // HOTNESS_OFF-NOT: hotness:
+ // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
+ // expected-remark@+2 {{foo should always be inlined (cost=always) (hotness: 30)}}
+ // expected-remark@+1 {{foo inlined into bar (hotness: 30)}}
+ sum += foo(x, x - 2);
+}
+
+int main(int argc, const char *argv[]) {
+ for (int i = 0; i < 30; i++)
+ // expected-remark@+1 {{bar should never be inlined}}
+ bar(argc);
+ return sum;
+}
OpenPOWER on IntegriCloud