aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-03-29 19:10:19 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-04-01 20:00:10 +0200
commit2a77544ad5911a38f81c0300385033fced1cc66d (patch)
tree5097f0a494bc5c6a10178f944296a0562f30a41b
parent6ee11c3b0f3605fa45dd7457b650b2d9d1c6ea74 (diff)
downloadllvm-2a77544ad5911a38f81c0300385033fced1cc66d.zip
llvm-2a77544ad5911a38f81c0300385033fced1cc66d.tar.gz
llvm-2a77544ad5911a38f81c0300385033fced1cc66d.tar.bz2
[SimplifyLibCalls] Erase replaced instructions
After RAUWing an instruction, also erase it. This makes sure we don't perform extra InstCombine iterations to clean up the garbage.
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 77fe6c1..10eb121 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -832,6 +832,7 @@ Value *LibCallSimplifier::optimizeStrStr(CallInst *CI, IRBuilderBase &B) {
B.CreateICmp(Old->getPredicate(), StrNCmp,
ConstantInt::getNullValue(StrNCmp->getType()), "cmp");
replaceAllUsesWith(Old, Cmp);
+ eraseFromParent(Old);
}
return CI;
}
@@ -2170,8 +2171,10 @@ Value *LibCallSimplifier::optimizeSinCosPi(CallInst *CI, IRBuilderBase &B) {
auto replaceTrigInsts = [this](SmallVectorImpl<CallInst *> &Calls,
Value *Res) {
- for (CallInst *C : Calls)
+ for (CallInst *C : Calls) {
replaceAllUsesWith(C, Res);
+ eraseFromParent(C);
+ }
};
replaceTrigInsts(SinCalls, Sin);