r307445 - Add sample PGO integration test to cover profile annotation and inlining.

Dehao Chen via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 7 15:01:47 PDT 2017


Author: dehao
Date: Fri Jul  7 15:01:47 2017
New Revision: 307445

URL: http://llvm.org/viewvc/llvm-project?rev=307445&view=rev
Log:
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

Modified:
    cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof
    cfe/trunk/test/CodeGen/pgo-sample.c

Modified: cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof?rev=307445&r1=307444&r2=307445&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof (original)
+++ cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof Fri Jul  7 15:01:47 2017
@@ -1,2 +1,7 @@
-bar:100:100
- 1: 2000
+bar:1000:1000
+ 1: 1000
+ 2: 0
+foo:1000:1000
+ 1:bar:1000
+  1: 1000
+  2: 1000

Modified: cfe/trunk/test/CodeGen/pgo-sample.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample.c?rev=307445&r1=307444&r2=307445&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/pgo-sample.c (original)
+++ cfe/trunk/test/CodeGen/pgo-sample.c Fri Jul  7 15:01:47 2017
@@ -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);
+}




More information about the cfe-commits mailing list