r271010 - Add instcombine pass if sampleprofile pass is enabled.

Dehao Chen via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 09:14:36 PDT 2016


Author: dehao
Date: Fri May 27 11:14:35 2016
New Revision: 271010

URL: http://llvm.org/viewvc/llvm-project?rev=271010&view=rev
Log:
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

Modified:
    cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=271010&r1=271009&r2=271010&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri May 27 11:14:35 2016
@@ -178,6 +178,11 @@ static void addAddDiscriminatorsPass(con
   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(Mo
   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(Mo
   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);
 }
 




More information about the cfe-commits mailing list