diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h b/llvm/include/llvm/Analysis/InlineAdvisor.h --- a/llvm/include/llvm/Analysis/InlineAdvisor.h +++ b/llvm/include/llvm/Analysis/InlineAdvisor.h @@ -222,7 +222,7 @@ bool invalidate(Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &) { // InlineAdvisor must be preserved across analysis invalidations. - return false; + return !Advisor; } bool tryCreate(InlineParams Params, InliningAdvisorMode Mode, StringRef ReplayFile); diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -1050,6 +1050,9 @@ IAA.clear(); + auto Inv = PreservedAnalyses::all(); + Inv.abandon(); + MAM.invalidate(M, Inv); // The ModulePassManager has already taken care of invalidating analyses. return PreservedAnalyses::all(); } diff --git a/llvm/test/Transforms/Inline/pr52118.ll b/llvm/test/Transforms/Inline/pr52118.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/Inline/pr52118.ll @@ -0,0 +1,9 @@ +; Test that the InlineAdvisor, upon being cleared, is re-created correctly. +; RUN: opt -S -passes="default,cgscc(inline)" < %s | FileCheck %s + +define double @foo() local_unnamed_addr { +entry: + ret double undef +} + +; CHECK: @foo