[llvm] [Inliner] Put inline history into IR as !inline_history metadata (PR #190876)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 17:48:28 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Arthur Eubanks (aeubanks)
<details>
<summary>Changes</summary>
(Reland of #<!-- -->190700 with checks for RefSCCs with one function with a self-reference, plus determinism fix)
(Reland of #<!-- -->190092 with verifier change to look through GlobalAliases)
So that it's preserved across all inline invocations rather than just one inliner pass run.
This prevents cases where devirtualization in the simplification pipeline uncovers inlining opportunities that should be discarded due to inline history, but we dropped the inline history between inliner pass runs, causing code size to blow up, sometimes exponentially.
For compile time reasons, we want to limit this to only call sites that have the potential to inline through SCCs, potentially with the help of devirtualization. This means that the callee is in a non-trivial (Ref)SCC, or the call site was previously an indirect call, which can potentially be devirtualized to call any function.
The CGSCCUpdater::InlinedInternalEdges logic still seems to be relevant even with this change, as monster_scc.ll blows up if I remove that code.
http://llvm-compile-time-tracker.com/compare.php?from=e830d88e8ae5f44a97cc76136a0a4e83aa9157c0&to=ed535e732fc41b79ab8efda2417886cbd0812f7f&stat=instructions:u
Fixes #<!-- -->186926.
---
Patch is 48.98 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/190876.diff
20 Files Affected:
- (modified) llvm/docs/LangRef.rst (+19)
- (modified) llvm/include/llvm/Analysis/InlineOrder.h (+9-10)
- (modified) llvm/include/llvm/IR/FixedMetadataKinds.def (+1)
- (modified) llvm/include/llvm/Transforms/Utils/Cloning.h (+19-17)
- (modified) llvm/lib/Analysis/InlineOrder.cpp (+11-23)
- (modified) llvm/lib/IR/Verifier.cpp (+18)
- (modified) llvm/lib/Transforms/IPO/AlwaysInliner.cpp (+4-4)
- (modified) llvm/lib/Transforms/IPO/Inliner.cpp (+26-36)
- (modified) llvm/lib/Transforms/IPO/ModuleInliner.cpp (+6-24)
- (modified) llvm/lib/Transforms/IPO/PartialInlining.cpp (+2-1)
- (modified) llvm/lib/Transforms/Utils/CloneFunction.cpp (+25-26)
- (modified) llvm/lib/Transforms/Utils/InlineFunction.cpp (+57-28)
- (modified) llvm/test/Transforms/Inline/debug-invoke.ll (+1-1)
- (added) llvm/test/Transforms/Inline/inline-history-2.ll (+25)
- (added) llvm/test/Transforms/Inline/inline-history-3.ll (+30)
- (removed) llvm/test/Transforms/Inline/inline-history-noinline.ll (-32)
- (added) llvm/test/Transforms/Inline/inline-history.ll (+102)
- (modified) llvm/test/Transforms/Inline/inline-recursive-fn2.ll (+1-1)
- (added) llvm/test/Verifier/inline-history-metadata.ll (+61)
- (modified) llvm/unittests/Analysis/InlineOrderPlugin/InlineOrderPlugin.cpp (+8-10)
``````````diff
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 5584e0828d3cd..f66cd37d9ec7e 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -8852,6 +8852,25 @@ Example:
!0 = !{ptr @a}
!1 = !{ptr @b}
+'``inline_history``' Metadata
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The ``inline_history`` metadata may be attached to a call instruction. It
+indicates that the call instruction has been inlined from the referenced
+functions. The call itself should not be inlined if it is a call to any of the
+referenced functions since that could result in infinite inlining as we
+continually inline through mutually recursive functions.
+
+This is intended to be added by and used by inliner passes.
+
+The metadata operands must all be function pointers or ``null``. ``null`` can
+appear when the referenced function is erased from the module, e.g. an internal
+function that has had all calls to it inlined.
+
+.. code-block:: text
+
+ call void @foo(), !inline_history !0
+
+ !0 = !{ptr @bar, null, ptr @baz}
Module Flags Metadata
=====================
diff --git a/llvm/include/llvm/Analysis/InlineOrder.h b/llvm/include/llvm/Analysis/InlineOrder.h
index bc96d546fda7a..459afcde47150 100644
--- a/llvm/include/llvm/Analysis/InlineOrder.h
+++ b/llvm/include/llvm/Analysis/InlineOrder.h
@@ -17,26 +17,26 @@ namespace llvm {
class CallBase;
template <typename Fn> class function_ref;
-template <typename T> class InlineOrder {
+class InlineOrder {
public:
virtual ~InlineOrder() = default;
virtual size_t size() = 0;
- virtual void push(const T &Elt) = 0;
+ virtual void push(CallBase *Elt) = 0;
- virtual T pop() = 0;
+ virtual CallBase *pop() = 0;
- virtual void erase_if(function_ref<bool(T)> Pred) = 0;
+ virtual void erase_if(function_ref<bool(CallBase *)> Pred) = 0;
bool empty() { return !size(); }
};
-LLVM_ABI std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
+LLVM_ABI std::unique_ptr<InlineOrder>
getDefaultInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
ModuleAnalysisManager &MAM, Module &M);
-LLVM_ABI std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
+LLVM_ABI std::unique_ptr<InlineOrder>
getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
ModuleAnalysisManager &MAM, Module &M);
@@ -54,10 +54,9 @@ class PluginInlineOrderAnalysis
public:
LLVM_ABI static AnalysisKey Key;
- typedef std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>> (
- *InlineOrderFactory)(FunctionAnalysisManager &FAM,
- const InlineParams &Params,
- ModuleAnalysisManager &MAM, Module &M);
+ typedef std::unique_ptr<InlineOrder> (*InlineOrderFactory)(
+ FunctionAnalysisManager &FAM, const InlineParams &Params,
+ ModuleAnalysisManager &MAM, Module &M);
PluginInlineOrderAnalysis(InlineOrderFactory Factory) : Factory(Factory) {
assert(Factory != nullptr &&
diff --git a/llvm/include/llvm/IR/FixedMetadataKinds.def b/llvm/include/llvm/IR/FixedMetadataKinds.def
index 0d79677d7079e..6d74aff4ae250 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -60,3 +60,4 @@ LLVM_FIXED_MD_KIND(MD_alloc_token, "alloc_token", 45)
LLVM_FIXED_MD_KIND(MD_implicit_ref, "implicit.ref", 46)
LLVM_FIXED_MD_KIND(MD_nofpclass, "nofpclass", 47)
LLVM_FIXED_MD_KIND(MD_call_target, "call_target", 48)
+LLVM_FIXED_MD_KIND(MD_inline_history, "inline_history", 49)
diff --git a/llvm/include/llvm/Transforms/Utils/Cloning.h b/llvm/include/llvm/Transforms/Utils/Cloning.h
index ff4b390eb3e6d..6b9aced467704 100644
--- a/llvm/include/llvm/Transforms/Utils/Cloning.h
+++ b/llvm/include/llvm/Transforms/Utils/Cloning.h
@@ -18,6 +18,7 @@
#define LLVM_TRANSFORMS_UTILS_CLONING_H
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/AssumptionCache.h"
@@ -88,6 +89,10 @@ struct ClonedCodeInfo {
/// check whether the main VMap mapping involves simplification or not.
DenseMap<const Value *, const Value *> OrigVMap;
+ // Cloned calls that were originally an indirect call. They may be direct or
+ // indirect after cloning.
+ SmallSetVector<const Value *, 4> OriginallyIndirectCalls;
+
ClonedCodeInfo() = default;
bool isSimplified(const Value *From, const Value *To) const {
@@ -225,11 +230,12 @@ LLVM_ABI void CloneFunctionBodyInto(
ValueMaterializer *Materializer = nullptr,
const MetadataPredicate *IdentityMD = nullptr);
-LLVM_ABI void CloneAndPruneIntoFromInst(
- Function *NewFunc, const Function *OldFunc, const Instruction *StartingInst,
- ValueToValueMapTy &VMap, bool ModuleLevelChanges,
- SmallVectorImpl<ReturnInst *> &Returns, const char *NameSuffix = "",
- ClonedCodeInfo *CodeInfo = nullptr);
+LLVM_ABI void
+CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
+ const Instruction *StartingInst,
+ ValueToValueMapTy &VMap, bool ModuleLevelChanges,
+ SmallVectorImpl<ReturnInst *> &Returns,
+ const char *NameSuffix, ClonedCodeInfo &CodeInfo);
/// This works exactly like CloneFunctionInto,
/// except that it does some simple constant prop and DCE on the fly. The
@@ -242,10 +248,11 @@ LLVM_ABI void CloneAndPruneIntoFromInst(
/// If ModuleLevelChanges is false, VMap contains no non-identity GlobalValue
/// mappings.
///
-LLVM_ABI void CloneAndPruneFunctionInto(
- Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap,
- bool ModuleLevelChanges, SmallVectorImpl<ReturnInst *> &Returns,
- const char *NameSuffix = "", ClonedCodeInfo *CodeInfo = nullptr);
+LLVM_ABI void
+CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
+ ValueToValueMapTy &VMap, bool ModuleLevelChanges,
+ SmallVectorImpl<ReturnInst *> &Returns,
+ const char *NameSuffix, ClonedCodeInfo &CodeInfo);
/// This class captures the data input to the InlineFunction call, and records
/// the auxiliary results produced by it.
@@ -311,6 +318,7 @@ LLVM_ABI void InlineFunctionImpl(CallBase &CB, InlineFunctionInfo &IFI,
bool MergeAttributes = false,
AAResults *CalleeAAR = nullptr,
bool InsertLifetime = true,
+ bool TrackInlineHistory = false,
Function *ForwardVarArgsTo = nullptr,
OptimizationRemarkEmitter *ORE = nullptr);
@@ -340,6 +348,7 @@ LLVM_ABI InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
bool MergeAttributes = false,
AAResults *CalleeAAR = nullptr,
bool InsertLifetime = true,
+ bool TrackInlineHistory = false,
Function *ForwardVarArgsTo = nullptr,
OptimizationRemarkEmitter *ORE = nullptr);
@@ -352,6 +361,7 @@ LLVM_ABI InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
bool MergeAttributes = false,
AAResults *CalleeAAR = nullptr,
bool InsertLifetime = true,
+ bool TrackInlineHistory = false,
Function *ForwardVarArgsTo = nullptr,
OptimizationRemarkEmitter *ORE = nullptr);
@@ -433,14 +443,6 @@ LLVM_ABI void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes,
LLVM_ABI void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes,
Instruction *IStart, Instruction *IEnd,
LLVMContext &Context, StringRef Ext);
-/// Check if Function F appears in the inline history chain.
-/// InlineHistory is a vector of (Function, ParentHistoryID) pairs.
-/// Returns true if F was already inlined in the chain leading to
-/// InlineHistoryID.
-LLVM_ABI bool
-inlineHistoryIncludes(Function *F, int InlineHistoryID,
- ArrayRef<std::pair<Function *, int>> InlineHistory);
-
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_CLONING_H
diff --git a/llvm/lib/Analysis/InlineOrder.cpp b/llvm/lib/Analysis/InlineOrder.cpp
index 8d920153f250d..f54e040ff83c7 100644
--- a/llvm/lib/Analysis/InlineOrder.cpp
+++ b/llvm/lib/Analysis/InlineOrder.cpp
@@ -199,10 +199,7 @@ class MLPriority {
int Cost = INT_MAX;
};
-template <typename PriorityT>
-class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
- using T = std::pair<CallBase *, int>;
-
+template <typename PriorityT> class PriorityInlineOrder : public InlineOrder {
bool hasLowerPriority(const CallBase *L, const CallBase *R) const {
const auto I1 = Priorities.find(L);
const auto I2 = Priorities.find(R);
@@ -243,31 +240,21 @@ class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
size_t size() override { return Heap.size(); }
- void push(const T &Elt) override {
- CallBase *CB = Elt.first;
- const int InlineHistoryID = Elt.second;
-
+ void push(CallBase *CB) override {
Heap.push_back(CB);
Priorities[CB] = PriorityT(CB, FAM, Params);
std::push_heap(Heap.begin(), Heap.end(), isLess);
- InlineHistoryMap[CB] = InlineHistoryID;
}
- T pop() override {
+ CallBase *pop() override {
assert(size() > 0);
pop_heap_adjust();
- CallBase *CB = Heap.pop_back_val();
- T Result = std::make_pair(CB, InlineHistoryMap[CB]);
- InlineHistoryMap.erase(CB);
- return Result;
+ return Heap.pop_back_val();
}
- void erase_if(function_ref<bool(T)> Pred) override {
- auto PredWrapper = [=](CallBase *CB) -> bool {
- return Pred(std::make_pair(CB, InlineHistoryMap[CB]));
- };
- llvm::erase_if(Heap, PredWrapper);
+ void erase_if(function_ref<bool(CallBase *)> Pred) override {
+ llvm::erase_if(Heap, Pred);
std::make_heap(Heap.begin(), Heap.end(), isLess);
}
@@ -284,7 +271,7 @@ class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
AnalysisKey llvm::PluginInlineOrderAnalysis::Key;
-std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
+std::unique_ptr<InlineOrder>
llvm::getDefaultInlineOrder(FunctionAnalysisManager &FAM,
const InlineParams &Params,
ModuleAnalysisManager &MAM, Module &M) {
@@ -309,9 +296,10 @@ llvm::getDefaultInlineOrder(FunctionAnalysisManager &FAM,
return nullptr;
}
-std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
-llvm::getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
- ModuleAnalysisManager &MAM, Module &M) {
+std::unique_ptr<InlineOrder> llvm::getInlineOrder(FunctionAnalysisManager &FAM,
+ const InlineParams &Params,
+ ModuleAnalysisManager &MAM,
+ Module &M) {
if (MAM.isPassRegistered<PluginInlineOrderAnalysis>()) {
LLVM_DEBUG(dbgs() << " Current used priority: plugin ---- \n");
return MAM.getResult<PluginInlineOrderAnalysis>(M).Factory(FAM, Params, MAM,
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index cf9131c66d6c3..4e760a02477b9 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -549,6 +549,7 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
void visitAccessGroupMetadata(const MDNode *MD);
void visitCapturesMetadata(Instruction &I, const MDNode *Captures);
void visitAllocTokenMetadata(Instruction &I, MDNode *MD);
+ void visitInlineHistoryMetadata(Instruction &I, MDNode *MD);
template <class Ty> bool isValidMetadataArray(const MDTuple &N);
#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) void visit##CLASS(const CLASS &N);
@@ -5619,6 +5620,20 @@ void Verifier::visitAllocTokenMetadata(Instruction &I, MDNode *MD) {
"expected integer constant", MD);
}
+void Verifier::visitInlineHistoryMetadata(Instruction &I, MDNode *MD) {
+ Check(isa<CallBase>(I), "!inline_history should only exist on calls", &I);
+ for (Metadata *Op : MD->operands()) {
+ // Can be null when a function is erased.
+ if (!Op)
+ continue;
+ Check(isa<ValueAsMetadata>(Op) &&
+ isa<Function>(cast<ValueAsMetadata>(Op)
+ ->getValue()
+ ->stripPointerCastsAndAliases()),
+ "!inline_history operands must be functions or null", MD);
+ }
+}
+
/// verifyInstruction - Verify that an instruction is well formed.
///
void Verifier::visitInstruction(Instruction &I) {
@@ -5851,6 +5866,9 @@ void Verifier::visitInstruction(Instruction &I) {
if (MDNode *MD = I.getMetadata(LLVMContext::MD_alloc_token))
visitAllocTokenMetadata(I, MD);
+ if (MDNode *MD = I.getMetadata(LLVMContext::MD_inline_history))
+ visitInlineHistoryMetadata(I, MD);
+
if (MDNode *N = I.getDebugLoc().getAsMDNode()) {
CheckDI(isa<DILocation>(N), "invalid !dbg metadata attachment", &I, N);
visitMDNode(*N, AreDebugLocsAllowed::Yes);
diff --git a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
index d0e309427d32e..080cb8ddb33fd 100644
--- a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
+++ b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
@@ -53,8 +53,9 @@ bool AlwaysInlineImpl(
BasicBlock *Block = CB.getParent();
InlineFunctionInfo IFI(GetAssumptionCache, &PSI);
- InlineResult Res = InlineFunction(CB, IFI, /*MergeAttributes=*/true,
- &GetAAR(Callee), InsertLifetime);
+ InlineResult Res = InlineFunction(
+ CB, IFI, /*MergeAttributes=*/true, &GetAAR(Callee), InsertLifetime,
+ /*TrackInlineHistory=*/NewCallSites != nullptr);
if (!Res.isSuccess()) {
ORE.emit([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "NotInlined", DLoc, Block)
@@ -140,8 +141,7 @@ bool AlwaysInlineImpl(
continue;
// Detect recursion.
- if (Callee == F ||
- inlineHistoryIncludes(Callee, InlineHistoryID, InlineHistory)) {
+ if (Callee == F) {
ORE.emit([&]() {
return OptimizationRemarkMissed("inline", "NotInlined",
CB->getDebugLoc(), CB->getParent())
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index d795fbbbe4120..d63dcf0614f14 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -231,7 +231,7 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
// this model, but it is uniformly spread across all the functions in the SCC
// and eventually they all become too large to inline, rather than
// incrementally maknig a single function grow in a super linear fashion.
- SmallVector<std::pair<CallBase *, int>, 16> Calls;
+ SmallVector<CallBase *, 16> Calls;
// Populate the initial list of calls in this SCC.
for (auto &N : InitialC) {
@@ -246,7 +246,7 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
if (auto *CB = dyn_cast<CallBase>(&I))
if (Function *Callee = CB->getCalledFunction()) {
if (!Callee->isDeclaration())
- Calls.push_back({CB, -1});
+ Calls.push_back(CB);
else if (!isa<IntrinsicInst>(I)) {
using namespace ore;
setInlineRemark(*CB, "unavailable definition");
@@ -269,12 +269,6 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
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
- // index into the InlineHistory vector.
- SmallVector<std::pair<Function *, int>, 16> InlineHistory;
-
// Track a set vector of inlined callees so that we can augment the caller
// with all of their edges in the call graph before pruning out the ones that
// got simplified away.
@@ -295,7 +289,7 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
// have the same caller, so we first set up some shared infrastructure for
// this caller. We also do any pruning we can at this layer on the caller
// alone.
- Function &F = *Calls[I].first->getCaller();
+ Function &F = *Calls[I]->getCaller();
LazyCallGraph::Node &N = *CG.lookup(F);
if (CG.lookupSCC(N) != C)
continue;
@@ -312,29 +306,17 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
// We bail out as soon as the caller has to change so we can update the
// call graph and prepare the context of that new caller.
bool DidInline = false;
- for (; I < (int)Calls.size() && Calls[I].first->getCaller() == &F; ++I) {
- auto &P = Calls[I];
- CallBase *CB = P.first;
- const int InlineHistoryID = P.second;
+ for (; I < (int)Calls.size() && Calls[I]->getCaller() == &F; ++I) {
+ CallBase *CB = Calls[I];
Function &Callee = *CB->getCalledFunction();
- if (InlineHistoryID != -1 &&
- inlineHistoryIncludes(&Callee, InlineHistoryID, InlineHistory)) {
- LLVM_DEBUG(dbgs() << "Skipping inlining due to history: " << F.getName()
- << " -> " << Callee.getName() << "\n");
- setInlineRemark(*CB, "recursive");
- // Set noinline so that we don't forget this decision across CGSCC
- // iterations.
- CB->setIsNoInline();
- continue;
- }
-
// Check if this inlining may repeat breaking an SCC apart that has
// already been split once before. In that case, inlining here may
// trigger infinite inlining, much like is prevented within the inliner
// itself by the InlineHistory above, but spread across CGSCC iterations
// and thus hidden from the full inline history.
- LazyCallGraph::SCC *CalleeSCC = CG.lookupSCC(*CG.lookup(Callee));
+ LazyCallGraph::Node &CalleeN = *CG.lookup(Callee);
+ LazyCallGraph::SCC *CalleeSCC = CG.lookupSCC(CalleeN);
if (CalleeSCC == C && UR.InlinedInternalEdges.count({&N, C})) {
LLVM_DEBUG(dbgs() << "Skipping inlining internal SCC edge from a node "
"previously split out of this SCC by inlining: "
@@ -367,9 +349,21 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
&FAM.getResult<BlockFrequencyAnalysis>(*(CB->getCaller())),
&FAM.getResult<BlockFrequencyAnalysis>(Callee));
+ // For compile time reasons we try to only track inline history for the
+ // calls where it may actually prevent inlining, which is inlining through
+ // an SCC. This can happen if the callee is in a non-trivial SCC/RefSCC,
+ // or if an inlined call site was an indirect call, which can be
+ // devirtualized to call any target by replacing the indirectly called
+ // function with a function pointer referenced by the caller. The indirect
+ // call case is handled within InlineFunction.
+ bool TrackInlineHistory = CalleeSCC->size() != 1 ||
+ CalleeSCC->getOuterRefSCC().size() != 1 ||
+ CalleeN->lookup(CalleeN) != nullptr;
+
InlineResult IR = InlineFunction(
*CB, IFI, /*MergeAttributes=*/true,
- &FAM.getResult<AAManager>(*CB->getCaller()), true, nullptr,
+ &FAM.getResult<AAManager>(*CB->getCaller()), /*InsertLifetime=*/true,
+ TrackInlineHistory, nullptr,
&FAM.getResult<OptimizationRemarkEmitterAnalysis>(*CB->getCaller()));
if (!IR.isSuccess()) {
Advice->recordUnsuccessfulInlining(IR);
@@ -388,9 +382,6 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
// Add any new callsites to defi...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/190876
More information about the llvm-commits
mailing list