[llvm] a8b7227 - [Inliner] Pass updated SCC to InlineAdvisor::onPassExit() (#96553)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 14:12:17 PDT 2024


Author: Arthur Eubanks
Date: 2024-06-28T14:12:14-07:00
New Revision: a8b722702db9bbf88f67a31c0c308865154576e2

URL: https://github.com/llvm/llvm-project/commit/a8b722702db9bbf88f67a31c0c308865154576e2
DIFF: https://github.com/llvm/llvm-project/commit/a8b722702db9bbf88f67a31c0c308865154576e2.diff

LOG: [Inliner] Pass updated SCC to InlineAdvisor::onPassExit() (#96553)

InitialC may be logically invalid, although iterating through it doesn't
crash. Always use the updated SCC.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/Inliner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index 1a7b9bc8e3e77..23ee23eb047f5 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -223,8 +223,6 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
   InlineAdvisor &Advisor = getAdvisor(MAMProxy, FAM, M);
   Advisor.onPassEntry(&InitialC);
 
-  auto AdvisorOnExit = make_scope_exit([&] { Advisor.onPassExit(&InitialC); });
-
   // We use a single common worklist for calls across the entire SCC. We
   // process these in-order and append new calls introduced during inlining to
   // the end. The PriorityInlineOrder is optional here, in which the smaller
@@ -279,12 +277,15 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
           }
         }
   }
-  if (Calls.empty())
-    return PreservedAnalyses::all();
 
   // Capture updatable variable for the current SCC.
   auto *C = &InitialC;
 
+  auto AdvisorOnExit = make_scope_exit([&] { Advisor.onPassExit(C); });
+
+  if (Calls.empty())
+    return PreservedAnalyses::all();
+
   // When inlining a callee produces new call sites, we want to keep track of
   // the fact that they were inlined from the callee.  This allows us to avoid
   // infinite inlining in some obscure cases.  To represent this, we use an


        


More information about the llvm-commits mailing list