summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/pgo-sample.c
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2017-07-07 22:01:47 +0000
committerDehao Chen <dehao@google.com>2017-07-07 22:01:47 +0000
commita3f8c80a357bc5a314c45d6f5a28cca718460cc1 (patch)
tree7c03f9fa2a4e28c32ae90d4801a5ecc819f586d5 /clang/test/CodeGen/pgo-sample.c
parent86ac9182e0dd51b9b62415e018d514a52de82f55 (diff)
downloadbcm5719-llvm-a3f8c80a357bc5a314c45d6f5a28cca718460cc1.tar.gz
bcm5719-llvm-a3f8c80a357bc5a314c45d6f5a28cca718460cc1.zip
Add sample PGO integration test to cover profile annotation and inlining.
Summary: The patch makes the integration test cover major sample PGO components. Reviewers: davidxl Reviewed By: davidxl Subscribers: sanjoy, cfe-commits Differential Revision: https://reviews.llvm.org/D34725 llvm-svn: 307445
Diffstat (limited to 'clang/test/CodeGen/pgo-sample.c')
-rw-r--r--clang/test/CodeGen/pgo-sample.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/clang/test/CodeGen/pgo-sample.c b/clang/test/CodeGen/pgo-sample.c
index e7d2fa61aa1..c6ba1085614 100644
--- a/clang/test/CodeGen/pgo-sample.c
+++ b/clang/test/CodeGen/pgo-sample.c
@@ -1,6 +1,34 @@
// Test if PGO sample use passes are invoked.
//
-// Ensure Pass PGOInstrumentationGenPass is invoked.
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s
-// CHECK: Remove unused exception handling info
-// CHECK: Sample profile pass
+// Ensure Pass SampleProfileLoader is invoked.
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=STRUCTURE
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -mllvm -inline-threshold=0 -emit-llvm -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -mllvm -inline-threshold=0 -emit-llvm -fexperimental-new-pass-manager -o - 2>&1 | FileCheck %s
+// STRUCTURE: Remove unused exception handling info
+// STRUCTURE: Sample profile pass
+
+void baz();
+
+// CHECK-LABEL: @callee(
+void callee(int t) {
+ for (int i = 0; i < t; i++)
+ baz();
+}
+
+// CHECK-LABEL: @bar(
+// cold call to callee should not be inlined.
+// CHECK: call void @callee
+void bar(int x) {
+ if (x < 100)
+ callee(x);
+}
+
+// CHECK-LABEL: @foo(
+// bar should be early-inlined because it is hot inline instance in profile.
+// callee should be inlined because it is hot callsite in the inline instance
+// of foo:bar.
+// CHECK-NOT: call void @callee
+// CHECK-NOT: call void @bar
+void foo(int x) {
+ bar(x);
+}
OpenPOWER on IntegriCloud