From: Dehao Chen Date: Tue, 21 Jun 2016 19:16:41 +0000 (+0000) Subject: Invoke PruneEH pass before Sample Profile pass. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7dc2dca11499af7a0bb8e0e16ee9ebe0636cfca2;p=clang Invoke PruneEH pass before Sample Profile pass. 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 --- diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index ac47c990d3..fc1a456c0c 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/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/test/CodeGen/Inputs/pgo-sample.prof b/test/CodeGen/Inputs/pgo-sample.prof new file mode 100644 index 0000000000..c5b8d9ef1a --- /dev/null +++ b/test/CodeGen/Inputs/pgo-sample.prof @@ -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 index 0000000000..e7d2fa61aa --- /dev/null +++ b/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