[clang] [llvm] [WPD]: Apply speculative WPD in non-lto mode. (PR #145031)

Hassnaa Hamdi via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 9 10:07:30 PDT 2025


================
@@ -1629,6 +1630,23 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
   if (!LTOPreLink)
     MPM.addPass(RelLookupTableConverterPass());
 
+  if (PTO.WholeProgramDevirt && LTOPhase == ThinOrFullLTOPhase::None) {
+    MPM.addPass(WholeProgramDevirtPass(/*ExportSummary*/ nullptr,
+                                       /*ImportSummary*/ nullptr,
+                                       /*InLTOMode=*/false));
+    MPM.addPass(LowerTypeTestsPass(nullptr, nullptr,
+                                   lowertypetests::DropTestKind::Assume));
+    if (EnableModuleInliner) {
+      MPM.addPass(ModuleInlinerPass(getInlineParamsFromOptLevel(Level),
----------------
hassnaaHamdi wrote:

It seems that the passes that eliminate the unused GVs are depending on the inliner where constructors get inlined so it becomes clear which GVs are used and which are not.
And the WPD needs single GV user of the vtable that contains the virtual function we need to devirtualize. 
So WPD depends on (GlobalOpt/GlobalDCE) which depend on the inliner.

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


More information about the llvm-commits mailing list