forked from OSchip/llvm-project
[SimpleLoopUnswitch] Drop uses of instructions before block deletion
Currently if instructions defined in a block are used in unreachable blocks and SimpleLoopUnswitch attempts deleting the block, it triggers assertion "Uses remain when a value is destroyed!". This patch fixes it by replacing all uses of instructions from BB with undefs before BB deletion. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D80551
This commit is contained in:
parent
d804b334ed
commit
706b22e3e4
|
@ -1574,6 +1574,11 @@ static void deleteDeadBlocksFromLoop(Loop &L,
|
|||
// 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue