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

llvm-svn: 271010
This commit is contained in:
Dehao Chen 2016-05-27 16:14:35 +00:00
parent 80b16d4135
commit ed8c1beefb
1 changed files with 10 additions and 2 deletions

View File

@ -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);
}