diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 17 | 
2 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index a0400721166..dac91950183 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -136,6 +136,9 @@ std::string getPGOFuncName(StringRef RawFuncName,  // (when \c InLTO is true): LTO's internalization privatizes many global linkage  // symbols. This happens after value profile annotation, but those internal  // linkage functions should not have a source prefix. +// Additionally, for ThinLTO mode, exported internal functions are promoted +// and renamed. We need to ensure that the original internal PGO name is +// used when computing the GUID that is compared against the profiled GUIDs.  // To differentiate compiler generated internal symbols from original ones,  // PGOFuncName meta data are created and attached to the original internal  // symbols in the value profile annotation step 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  | 

