[llvm] dffc503 - Revert "[SimplifyLibCalls] Erase replaced instructions"
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 08:32:06 PDT 2020
Author: Benjamin Kramer
Date: 2020-04-02T17:30:47+02:00
New Revision: dffc5031874edff22d4462ce665acd309ecb9cdc
URL: https://github.com/llvm/llvm-project/commit/dffc5031874edff22d4462ce665acd309ecb9cdc
DIFF: https://github.com/llvm/llvm-project/commit/dffc5031874edff22d4462ce665acd309ecb9cdc.diff
LOG: Revert "[SimplifyLibCalls] Erase replaced instructions"
This reverts commit 2a77544ad5911a38f81c0300385033fced1cc66d. This
introduces a use-after-free in Transforms/InstCombine/sincospi.ll.
Found by asan.
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 10eb1212a591..77fe6c1cb12a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -832,7 +832,6 @@ Value *LibCallSimplifier::optimizeStrStr(CallInst *CI, IRBuilderBase &B) {
B.CreateICmp(Old->getPredicate(), StrNCmp,
ConstantInt::getNullValue(StrNCmp->getType()), "cmp");
replaceAllUsesWith(Old, Cmp);
- eraseFromParent(Old);
}
return CI;
}
@@ -2171,10 +2170,8 @@ 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