diff options
author | Dehao Chen <dehao@google.com> | 2016-06-23 20:13:10 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2016-06-23 20:13:10 +0000 |
commit | bd3ed3c55bfca8d99c67d00300c23bc661a0919a (patch) | |
tree | 2e0cae3df8b308b77fd58fc13e8b80341e62984a /clang/lib/CodeGen/BackendUtil.cpp | |
parent | 8d4b0eddd613567b4f29088972b43104d8234f94 (diff) | |
download | bcm5719-llvm-bd3ed3c55bfca8d99c67d00300c23bc661a0919a.tar.gz bcm5719-llvm-bd3ed3c55bfca8d99c67d00300c23bc661a0919a.zip |
Invoke simplifycfg and sroa before instcombine.
Summary: InstCombine needs to be performed after simplifycfg and sroa, otherwise it may make bad optimization decisions.
Reviewers: davidxl, wmi, dnovillo
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D21568
llvm-svn: 273606
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 36706696791..310486e37f0 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -178,8 +178,14 @@ static void addAddDiscriminatorsPass(const PassManagerBuilder &Builder, PM.add(createAddDiscriminatorsPass()); } -static void addInstructionCombiningPass(const PassManagerBuilder &Builder, - legacy::PassManagerBase &PM) { +static void addCleanupPassesForSampleProfiler( + const PassManagerBuilder &Builder, legacy::PassManagerBase &PM) { + // instcombine is needed before sample profile annotation because it converts + // certain function calls to be inlinable. simplifycfg and sroa are needed + // before instcombine for necessary preparation. E.g. load store is eliminated + // properly so that instcombine will not introduce unecessary liverange. + PM.add(createCFGSimplificationPass()); + PM.add(createSROAPass()); PM.add(createInstructionCombiningPass()); } @@ -492,7 +498,7 @@ void EmitAssemblyHelper::CreatePasses(ModuleSummaryIndex *ModuleSummary) { MPM->add(createPruneEHPass()); MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile)); PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, - addInstructionCombiningPass); + addCleanupPassesForSampleProfiler); } PMBuilder.populateFunctionPassManager(*FPM); |