aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorYevgeny Rouban <yrouban@azul.com>2020-09-14 11:42:23 +0700
committerYevgeny Rouban <yrouban@azul.com>2020-09-14 11:46:34 +0700
commit88690a965892e82cac05a162a9d10e2ce4e2355f (patch)
tree39a41dc1fd6b3e83e8faebdda6cfb72a581ef939 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent6e42cadf106ccdc7759dd8af113ecf797220de47 (diff)
downloadllvm-88690a965892e82cac05a162a9d10e2ce4e2355f.zip
llvm-88690a965892e82cac05a162a9d10e2ce4e2355f.tar.gz
llvm-88690a965892e82cac05a162a9d10e2ce4e2355f.tar.bz2
[CodeGenPrepare] Fix zapping dead operands of assume
This patch fixes a problem of the commit 52cc97a0. A test case is created to demonstrate the crash caused by the instruction iterator invalidated by the recursive removal of dead operands of assume. The solution restarts from the blocks's first instruction in case CurInstIterator is invalidated by RecursivelyDeleteTriviallyDeadInstructions(). Reviewed By: bkramer Differential Revision: https://reviews.llvm.org/D87434
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 529975c..bb0bad7 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2047,9 +2047,11 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, bool &ModifiedDT) {
Value *Operand = II->getOperand(0);
II->eraseFromParent();
// Prune the operand, it's most likely dead.
- RecursivelyDeleteTriviallyDeadInstructions(
- Operand, TLInfo, nullptr,
- [&](Value *V) { removeAllAssertingVHReferences(V); });
+ resetIteratorIfInvalidatedWhileCalling(BB, [&]() {
+ RecursivelyDeleteTriviallyDeadInstructions(
+ Operand, TLInfo, nullptr,
+ [&](Value *V) { removeAllAssertingVHReferences(V); });
+ });
return true;
}