[llvm] [Inliner] Pass updated SCC to InlineAdvisor::onPassExit() (PR #96553)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 13:48:28 PDT 2024
https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/96553
InitialC may be logically invalid, although iterating through it doesn't crash. Always use the updated SCC.
>From 84ebd5f4a9cdbb8c556cd20cf23e893422e7fb79 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Mon, 24 Jun 2024 20:13:05 +0000
Subject: [PATCH] [Inliner] Pass updated SCC to InlineAdvisor::onPassExit()
InitialC may be logically invalid, although iterating through it doesn't
crash. Always use the updated SCC.
---
llvm/lib/Transforms/IPO/Inliner.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
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