[PATCH] D111586: [Inline] Make sure the InlineAdvisor is correctly cleared.

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 11 16:46:40 PDT 2021


mtrofin created this revision.
mtrofin added reviewers: aeubanks, jsilvanus.
Herald added subscribers: ormris, hiraditya, eraman.
mtrofin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If another inlining session came after a ModuleInlinerWrapperPass, the
advisor alanysis would still be cached, but its Result would be cleared.
We need to clear both.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111586

Files:
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Transforms/Inline/pr52118.ll


Index: llvm/test/Transforms/Inline/pr52118.ll
===================================================================
--- /dev/null
+++ 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<O1>,cgscc(inline)" < %s | FileCheck %s
+
+define double @foo() local_unnamed_addr {
+entry:
+  ret double undef
+}
+
+; CHECK: @foo
Index: llvm/lib/Transforms/IPO/Inliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -1050,6 +1050,9 @@
 
   IAA.clear();
 
+  auto Inv = PreservedAnalyses::all();
+  Inv.abandon<InlineAdvisorAnalysis>();
+  MAM.invalidate(M, Inv);
   // The ModulePassManager has already taken care of invalidating analyses.
   return PreservedAnalyses::all();
 }
Index: llvm/include/llvm/Analysis/InlineAdvisor.h
===================================================================
--- llvm/include/llvm/Analysis/InlineAdvisor.h
+++ 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111586.378825.patch
Type: text/x-patch
Size: 1471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211011/078fc658/attachment.bin>


More information about the llvm-commits mailing list