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

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 13:48:56 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Arthur Eubanks (aeubanks)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/96553.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/IPO/Inliner.cpp (+5-4) 


``````````diff
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

``````````

</details>


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


More information about the llvm-commits mailing list