diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-08-29 22:46:56 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-08-29 22:46:56 +0000 |
commit | 8c1bc986b598fd352262c53e6e36307d02036d3c (patch) | |
tree | f3f891c88de04d62081060fbb452ea37c04f56bb /llvm/lib/Transforms | |
parent | fafcb85e7964ce28c7a2bf38f6ba864fbfa6c0b6 (diff) | |
download | bcm5719-llvm-8c1bc986b598fd352262c53e6e36307d02036d3c.tar.gz bcm5719-llvm-8c1bc986b598fd352262c53e6e36307d02036d3c.zip |
[ThinLTO] Indirect call promotion fixes for promoted local functions
Summary:
Fix a couple issues limiting the application of indirect call promotion
in ThinLTO mode:
- Invoke indirect call promotion before globalopt, since it may
eliminate imported functions which appear unreferenced.
- Invoke indirect call promotion with InLTO=true so that the PGOFuncName
metadata is used to get the name for locals which would have been
renamed during promotion.
Reviewers: davidxl, mehdi_amini
Subscribers: Prazek, llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D24004
llvm-svn: 280024
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 71e479aac55..fd3aadb68fb 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -405,6 +405,16 @@ void PassManagerBuilder::populateModulePassManager( addInitialAliasAnalysisPasses(MPM); + // For ThinLTO there are two passes of indirect call promotion. The + // first is during the compile phase when PerformThinLTO=false and + // intra-module indirect call targets are promoted. The second is during + // the ThinLTO backend when PerformThinLTO=true, when we promote imported + // inter-module indirect calls. For that we perform indirect call promotion + // earlier in the pass pipeline, here before globalopt. Otherwise imported + // available_externally functions look unreferenced and are removed. + if (PerformThinLTO) + MPM.add(createPGOIndirectCallPromotionLegacyPass(/*InLTO = */ true)); + if (!DisableUnitAtATime) { // Infer attributes about declarations if possible. MPM.add(createInferFunctionAttrsLegacyPass()); @@ -427,11 +437,12 @@ void PassManagerBuilder::populateModulePassManager( /// PGO instrumentation is added during the compile phase for ThinLTO, do /// not run it a second time addPGOInstrPasses(MPM); + // Indirect call promotion that promotes intra-module targets only. + // For ThinLTO this is done earlier due to interactions with globalopt + // for imported functions. + MPM.add(createPGOIndirectCallPromotionLegacyPass()); } - // Indirect call promotion that promotes intra-module targets only. - MPM.add(createPGOIndirectCallPromotionLegacyPass()); - if (EnableNonLTOGlobalsModRef) // We add a module alias analysis pass here. In part due to bugs in the // analysis infrastructure this "works" in that the analysis stays alive |