From: Dehao Chen Date: Fri, 27 May 2016 16:14:35 +0000 (+0000) Subject: Add instcombine pass if sampleprofile pass is enabled. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35537a7dad8b4622bccb4730bbbe165acad50d09;p=clang Add instcombine pass if sampleprofile pass is enabled. Summary: Sample profile pass need to have instcombine pass. A related change is http://reviews.llvm.org/D17742. But we should not explicitly add dependency between to non-analysis passes. So we add the dependency here. Reviewers: davidxl, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20502 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271010 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 5b9f77cc49..2577eecdf8 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -178,6 +178,11 @@ static void addAddDiscriminatorsPass(const PassManagerBuilder &Builder, PM.add(createAddDiscriminatorsPass()); } +static void addInstructionCombiningPass(const PassManagerBuilder &Builder, + legacy::PassManagerBase &PM) { + PM.add(createInstructionCombiningPass()); +} + static void addBoundsCheckingPass(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM) { PM.add(createBoundsCheckingPass()); @@ -441,7 +446,6 @@ void EmitAssemblyHelper::CreatePasses(ModuleSummaryIndex *ModuleSummary) { legacy::FunctionPassManager *FPM = getPerFunctionPasses(); if (CodeGenOpts.VerifyModule) FPM->add(createVerifierPass()); - PMBuilder.populateFunctionPassManager(*FPM); // Set up the per-module pass manager. if (!CodeGenOpts.RewriteMapFiles.empty()) @@ -480,9 +484,13 @@ void EmitAssemblyHelper::CreatePasses(ModuleSummaryIndex *ModuleSummary) { if (CodeGenOpts.hasProfileIRUse()) PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath; - if (!CodeGenOpts.SampleProfileFile.empty()) + if (!CodeGenOpts.SampleProfileFile.empty()) { MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile)); + PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, + addInstructionCombiningPass); + } + PMBuilder.populateFunctionPassManager(*FPM); PMBuilder.populateModulePassManager(*MPM); }