[llvm] [ctx_prof] Automatically convert available external linkage to local for modules with contextual roots (PR #109203)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 06:41:14 PDT 2024


================
@@ -125,8 +126,16 @@ static bool eliminateAvailableExternally(Module &M) {
 }
 
 PreservedAnalyses
-EliminateAvailableExternallyPass::run(Module &M, ModuleAnalysisManager &) {
-  if (!eliminateAvailableExternally(M))
-    return PreservedAnalyses::all();
+EliminateAvailableExternallyPass::run(Module &M, ModuleAnalysisManager &MAM) {
+  auto *CtxProf = MAM.getCachedResult<CtxProfAnalysis>(M);
+  // Convert to local instead of eliding if we use contextual profiling in this
+  // module. This is because the IPO decisions performed with contextual
+  // information will likely differ from decisions made without. For a function
+  // that's imported, its optimizations will, thus, differ, and be specialized
+  // for this contextual information. Eliding it in favor of the original would
+  // undo these optimizations.
+  if (!eliminateAvailableExternally(M, /*Convert=*/(CtxProf && !!(*CtxProf))))
+    ;
----------------
mtrofin wrote:

yup. thanks for flagging. Fixed in 35ae7ee.

https://github.com/llvm/llvm-project/pull/109203


More information about the llvm-commits mailing list