aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2020-08-28 19:31:36 +0200
committerBenjamin Kramer <benny.kra@googlemail.com>2020-08-28 20:52:22 +0200
commit52cc97a0db2d4c20655d4df7f2ae5c087ee5807b (patch)
tree240d775277834651c67a9ba2434fede167bfe74b /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent8bd895cac0cd4eaf76b9bb296a995e5ee485205b (diff)
downloadllvm-52cc97a0db2d4c20655d4df7f2ae5c087ee5807b.zip
llvm-52cc97a0db2d4c20655d4df7f2ae5c087ee5807b.tar.gz
llvm-52cc97a0db2d4c20655d4df7f2ae5c087ee5807b.tar.bz2
[CodeGenPrepare] Zap the argument of llvm.assume when deleting it
We know that the argument is mostly likely dead, so we can purge it early. Otherwise it would make it to codegen, and can block further optimizations.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 2034fd0..3272f36 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2044,7 +2044,12 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, bool &ModifiedDT) {
switch (II->getIntrinsicID()) {
default: break;
case Intrinsic::assume: {
+ Value *Operand = II->getOperand(0);
II->eraseFromParent();
+ // Prune the operand, it's most likely dead.
+ RecursivelyDeleteTriviallyDeadInstructions(
+ Operand, TLInfo, nullptr,
+ [&](Value *V) { removeAllAssertingVHReferences(V); });
return true;
}