[PATCH] D112473: [AlwaysInliner] Invalidate analyses when we delete functions

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 25 13:36:55 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a9db7367dce: [AlwaysInliner] Invalidate analyses when we delete functions (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112473/new/

https://reviews.llvm.org/D112473

Files:
  llvm/lib/Transforms/IPO/AlwaysInliner.cpp
  llvm/test/Transforms/Inline/always-inline-invalidate.ll


Index: llvm/test/Transforms/Inline/always-inline-invalidate.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Inline/always-inline-invalidate.ll
@@ -0,0 +1,8 @@
+; RUN: opt -passes='require<no-op-module>,always-inline' -disable-output < %s 2>&1 -debug-pass-manager | FileCheck %s
+
+; CHECK: Invalidating {{.*}} NoOpModuleAnalysis
+; CHECK-NOT: @f
+
+define internal void @f() alwaysinline {
+  unreachable
+}
Index: llvm/lib/Transforms/IPO/AlwaysInliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AlwaysInliner.cpp
+++ llvm/lib/Transforms/IPO/AlwaysInliner.cpp
@@ -108,8 +108,10 @@
   // Delete the non-comdat ones from the module and also from our vector.
   auto NonComdatBegin = partition(
       InlinedFunctions, [&](Function *F) { return F->hasComdat(); });
-  for (Function *F : make_range(NonComdatBegin, InlinedFunctions.end()))
+  for (Function *F : make_range(NonComdatBegin, InlinedFunctions.end())) {
     M.getFunctionList().erase(F);
+    Changed = true;
+  }
   InlinedFunctions.erase(NonComdatBegin, InlinedFunctions.end());
 
   if (!InlinedFunctions.empty()) {
@@ -117,8 +119,10 @@
     // are not actually dead.
     filterDeadComdatFunctions(M, InlinedFunctions);
     // The remaining functions are actually dead.
-    for (Function *F : InlinedFunctions)
+    for (Function *F : InlinedFunctions) {
       M.getFunctionList().erase(F);
+      Changed = true;
+    }
   }
 
   return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112473.382111.patch
Type: text/x-patch
Size: 1588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211025/b8f07d9f/attachment.bin>


More information about the llvm-commits mailing list