[PATCH] D67941: Invalidate assumption cache before outlining.

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 23 16:27:07 PDT 2019


hiraditya created this revision.
hiraditya added a reviewer: compnerd.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Assumption cache pointers become stale after function splitting and dependencies from old function can't be removed as such.
See D67936 <https://reviews.llvm.org/D67936> for more context and testcase.


Repository:
  rL LLVM

https://reviews.llvm.org/D67941

Files:
  llvm/lib/Transforms/Utils/CodeExtractor.cpp


Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1277,13 +1277,6 @@
 
     // Insert this basic block into the new function
     newBlocks.push_back(Block);
-
-    // Remove @llvm.assume calls that were moved to the new function from the
-    // old function's assumption cache.
-    if (AC)
-      for (auto &I : *Block)
-        if (match(&I, m_Intrinsic<Intrinsic::assume>()))
-          AC->unregisterAssumption(cast<CallInst>(&I));
   }
 }
 
@@ -1375,6 +1368,16 @@
     }
   }
 
+  for (BasicBlock *Block : Blocks) {
+    // Remove @llvm.assume calls that were moved to the new function from the
+    // old function's assumption cache.
+    if (AC)
+      for (auto &I : *Block)
+        if (match(&I, m_Intrinsic<Intrinsic::assume>()))
+          AC->unregisterAssumption(cast<CallInst>(&I));
+  }
+
+
   // If we have any return instructions in the region, split those blocks so
   // that the return is not in the region.
   splitReturnBlocks();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67941.221432.patch
Type: text/x-patch
Size: 1125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190923/8b8ef522/attachment.bin>


More information about the llvm-commits mailing list