[PATCH] D80551: [SimpleLoopUnswitch] Drop uses of instructions before block deletion

Daniil Suchkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 27 04:49:48 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG706b22e3e446: [SimpleLoopUnswitch] Drop uses of instructions before block deletion (authored by DaniilSuchkov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80551

Files:
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/test/Transforms/SimpleLoopUnswitch/dead-blocks-uses-in-unreachablel-blocks.ll


Index: llvm/test/Transforms/SimpleLoopUnswitch/dead-blocks-uses-in-unreachablel-blocks.ll
===================================================================
--- llvm/test/Transforms/SimpleLoopUnswitch/dead-blocks-uses-in-unreachablel-blocks.ll
+++ llvm/test/Transforms/SimpleLoopUnswitch/dead-blocks-uses-in-unreachablel-blocks.ll
@@ -1,4 +1,3 @@
-; XFAIL: *
 ; REQUIRES: asserts
 ; RUN: opt < %s -passes='unswitch<nontrivial>' -disable-output
 ; RUN: opt < %s -simple-loop-unswitch -enable-nontrivial-unswitch -disable-output
Index: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -1574,6 +1574,11 @@
     // Check that the dominator tree has already been updated.
     assert(!DT.getNode(BB) && "Should already have cleared domtree!");
     LI.changeLoopFor(BB, nullptr);
+    // Drop all uses of the instructions to make sure we won't have dangling
+    // uses in other blocks.
+    for (auto &I : *BB)
+      if (!I.use_empty())
+        I.replaceAllUsesWith(UndefValue::get(I.getType()));
     BB->dropAllReferences();
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80551.266489.patch
Type: text/x-patch
Size: 1214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200527/11d584f3/attachment.bin>


More information about the llvm-commits mailing list