diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2019-11-11 09:56:03 -0500 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2019-11-11 09:56:03 -0500 |
| commit | 29f5d1670c368589b2555932551360721da7799a (patch) | |
| tree | bceecc7f4a72d32ce4f210e635bae3453ac34223 /llvm/lib | |
| parent | 3db8a3ef86e7b3331ab466a78c10a62be9e69829 (diff) | |
| download | bcm5719-llvm-29f5d1670c368589b2555932551360721da7799a.tar.gz bcm5719-llvm-29f5d1670c368589b2555932551360721da7799a.zip | |
Revert "[InstCombine] avoid crash from deleting an instruction that still has uses (PR43723) (3rd try)"
This reverts commit 3db8a3ef86e7b3331ab466a78c10a62be9e69829.
This caused a different memory-sanitizer failure than earlier attempts,
but it's still not right.
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 3b137c3f1c3..b1828d0fe32 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2340,21 +2340,13 @@ static bool isAllocSiteRemovable(Instruction *AI, return false; LLVM_FALLTHROUGH; } + case Intrinsic::invariant_start: case Intrinsic::invariant_end: case Intrinsic::lifetime_start: case Intrinsic::lifetime_end: case Intrinsic::objectsize: Users.emplace_back(I); continue; - case Intrinsic::invariant_start: - // Only delete this if it has no uses or a single 'end' use. - if (I->use_empty()) - Users.emplace_back(I); - else if (I->hasOneUse() && - match(I->user_back(), - m_Intrinsic<Intrinsic::invariant_end>())) - Users.emplace_back(I); - continue; } } @@ -2402,13 +2394,14 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) { if (isAllocSiteRemovable(&MI, Users, &TLI)) { for (unsigned i = 0, e = Users.size(); i != e; ++i) { + // Lowering all @llvm.objectsize calls first because they may + // use a bitcast/GEP of the alloca we are removing. if (!Users[i]) continue; Instruction *I = cast<Instruction>(&*Users[i]); + if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) { - // Lowering all @llvm.objectsize calls first because they may - // use a bitcast/GEP of the alloca we are removing. if (II->getIntrinsicID() == Intrinsic::objectsize) { Value *Result = lowerObjectSizeCall(II, DL, &TLI, /*MustSucceed=*/true); @@ -2416,13 +2409,6 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) { eraseInstFromFunction(*I); Users[i] = nullptr; // Skip examining in the next loop. } - // Erase llvm.invariant.start because we expect that it is used by - // llvm.invariant.end that we will remove below. - if (II->getIntrinsicID() == Intrinsic::invariant_start) { - replaceInstUsesWith(*I, UndefValue::get(I->getType())); - eraseInstFromFunction(*I); - Users[i] = nullptr; // Skip examining in the next loop. - } } } for (unsigned i = 0, e = Users.size(); i != e; ++i) { |

