summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp1
-rw-r--r--clang/test/CodeGen/Inputs/pgo-sample.prof2
-rw-r--r--clang/test/CodeGen/pgo-sample.c6
3 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index ac47c990d38..fc1a456c0c7 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -488,6 +488,7 @@ void EmitAssemblyHelper::CreatePasses(ModuleSummaryIndex *ModuleSummary) {
PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
if (!CodeGenOpts.SampleProfileFile.empty()) {
+ MPM->add(createPruneEHPass());
MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
addInstructionCombiningPass);
diff --git a/clang/test/CodeGen/Inputs/pgo-sample.prof b/clang/test/CodeGen/Inputs/pgo-sample.prof
new file mode 100644
index 00000000000..c5b8d9ef1a8
--- /dev/null
+++ b/clang/test/CodeGen/Inputs/pgo-sample.prof
@@ -0,0 +1,2 @@
+bar:100:100
+ 1: 2000
diff --git a/clang/test/CodeGen/pgo-sample.c b/clang/test/CodeGen/pgo-sample.c
new file mode 100644
index 00000000000..e7d2fa61aa1
--- /dev/null
+++ b/clang/test/CodeGen/pgo-sample.c
@@ -0,0 +1,6 @@
+// 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
OpenPOWER on IntegriCloud