Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

aeubanks
Copy link
Contributor

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

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

llvmbot commented Jun 24, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Arthur Eubanks (aeubanks)

Changes

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

Copy link
Member

@mtrofin mtrofin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this NFC?

@aeubanks
Copy link
Contributor Author

Is this NFC?

it's fixing a bug with the SCC we pass to onPassExit, but I'm actually not sure how observable this is, it was just something I randomly noticed looking at the code

@aeubanks aeubanks merged commit a8b7227 into llvm:main Jun 28, 2024
9 checks passed
@aeubanks aeubanks deleted the inline-scc branch June 28, 2024 21:12
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
InitialC may be logically invalid, although iterating through it doesn't
crash. Always use the updated SCC.
luxufan pushed a commit to luxufan/llvm-project that referenced this pull request Mar 31, 2025
InitialC may be logically invalid, although iterating through it doesn't
crash. Always use the updated SCC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants