[llvm] 2a77544 - [SimplifyLibCalls] Erase replaced instructions
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 11:00:55 PDT 2020
Author: Nikita Popov
Date: 2020-04-01T20:00:10+02:00
New Revision: 2a77544ad5911a38f81c0300385033fced1cc66d
URL: https://github.com/llvm/llvm-project/commit/2a77544ad5911a38f81c0300385033fced1cc66d
DIFF: https://github.com/llvm/llvm-project/commit/2a77544ad5911a38f81c0300385033fced1cc66d.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 77fe6c1cb12a..10eb1212a591 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);
More information about the llvm-commits
mailing list