Revert "[SimplifyLibCalls] Erase replaced instructions"

This reverts commit 2a77544ad5. This
introduces a use-after-free in Transforms/InstCombine/sincospi.ll.
Found by asan.
This commit is contained in:
Benjamin Kramer 2020-04-02 17:30:47 +02:00
parent bacade1ddf
commit dffc503187
1 changed files with 1 additions and 4 deletions

View File

@ -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);