================
@@ -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) {
----------------
hassnaaHamdi wrote:

I think the inliner also is crucial for the global optimisation that both 
passes of GlobalOpt and GlobalDCE do.
As an example, if we disabled the inliner, the GVs will not be optimised, and 
as a result the devirtualization will not work.
So I think the inliner is needed to be run firstly.
Ex for the output when the inliner is enabled and when it's disabled : 
https://godbolt.org/z/r8oKh9qxa 

So the inliner at the beginning is crucial for the devirtualization feature to 
work.
And the inliner at the end is useful for making the most gain out of the 
devirtualization because the devirtualized functions can be inlined.

https://github.com/llvm/llvm-project/pull/159685
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to