[clang] [llvm] [Clang]: Enable speculative devirtualization (PR #159685)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 08:10:06 PST 2025


================
@@ -1641,6 +1642,24 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
   if (!LTOPreLink)
     MPM.addPass(RelLookupTableConverterPass());
 
+  if (PTO.DevirtualizeSpeculatively && LTOPhase == ThinOrFullLTOPhase::None) {
+    MPM.addPass(WholeProgramDevirtPass(
+        /*ExportSummary*/ nullptr,
+        /*ImportSummary*/ nullptr,
+        /*DevirtSpeculatively*/ PTO.DevirtualizeSpeculatively));
+    MPM.addPass(LowerTypeTestsPass(nullptr, nullptr,
+                                   lowertypetests::DropTestKind::Assume));
+    if (EnableModuleInliner) {
----------------
teresajohnson wrote:

(with that latter suggestion, you wouldn't add wpd or the inliner here at all, wpd would instead get invoked during the existing ModuleInlinerWrapperPass / DevirtSCCRepeatedPass invocation)

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


More information about the llvm-commits mailing list