]> granicus.if.org Git - clang/commitdiff
Invoke PruneEH pass before Sample Profile pass.
authorDehao Chen <dehao@google.com>
Tue, 21 Jun 2016 19:16:41 +0000 (19:16 +0000)
committerDehao Chen <dehao@google.com>
Tue, 21 Jun 2016 19:16:41 +0000 (19:16 +0000)
Summary: We need to call PruneEH pass before AutoFDO pass so that some EH-related calls can get inlined in Sample Profile pass.

Reviewers: davidxl, dnovillo

Subscribers: junbuml, llvm-commits

Differential Revision: http://reviews.llvm.org/D21197

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273298 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/BackendUtil.cpp
test/CodeGen/Inputs/pgo-sample.prof [new file with mode: 0644]
test/CodeGen/pgo-sample.c [new file with mode: 0644]

index ac47c990d38f21e16f8aacc3dec027aa5609cfdd..fc1a456c0c79d4f640b24b0a3bacbcefbe73cf26 100644 (file)
@@ -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/test/CodeGen/Inputs/pgo-sample.prof b/test/CodeGen/Inputs/pgo-sample.prof
new file mode 100644 (file)
index 0000000..c5b8d9e
--- /dev/null
@@ -0,0 +1,2 @@
+bar:100:100
+ 1: 2000
diff --git a/test/CodeGen/pgo-sample.c b/test/CodeGen/pgo-sample.c
new file mode 100644 (file)
index 0000000..e7d2fa6
--- /dev/null
@@ -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