[clang] [llvm] [WPD]: Apply speculative WPD in non-lto mode. (PR #145031)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 4 10:56:25 PDT 2025
================
@@ -794,12 +815,29 @@ PreservedAnalyses WholeProgramDevirtPass::run(Module &M,
return FAM.getResult<DominatorTreeAnalysis>(F);
};
if (UseCommandLine) {
- if (!DevirtModule::runForTesting(M, AARGetter, OREGetter, LookupDomTree))
+ if (TestNoLTOMode)
+ // we are outside LTO mode. enable speculative devirtualization:
+ DevirtCheckMode = WPDCheckMode::Fallback;
+ if (!DevirtModule::runForTesting(M, AARGetter, OREGetter, LookupDomTree,
+ !TestNoLTOMode))
return PreservedAnalyses::all();
return PreservedAnalyses::none();
}
+ std::optional<ModuleSummaryIndex> Index;
+ // Force Fallback mode as it's safe in case it's non-LTO mode where
----------------
teresajohnson wrote:
Under the proposed option, we could do this speculative devirtualization in LTO mode where there is public visibility, but it looks like that would take some additional code restructuring/tracking. For now maybe just guard this by the proposed more general cl::opt, with a TODO to support using the speculative fallback mode just for vtables with public visibility. In fact, non-speculative devirt can kick in for hidden vis classes even in non-LTO mode.
https://github.com/llvm/llvm-project/pull/145031
More information about the llvm-commits
mailing list