1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[CodeGenPrepare] Simplify code. NFCI.

This commit is contained in:
Benjamin Kramer 2020-09-11 11:24:08 +02:00
parent 336548370d
commit 28b9fdaf5e

View File

@ -5274,22 +5274,11 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
// If we have no uses, recursively delete the value and all dead instructions
// using it.
if (Repl->use_empty()) {
// This can cause recursive deletion, which can invalidate our iterator.
// Use a WeakTrackingVH to hold onto it in case this happens.
Value *CurValue = &*CurInstIterator;
WeakTrackingVH IterHandle(CurValue);
BasicBlock *BB = CurInstIterator->getParent();
RecursivelyDeleteTriviallyDeadInstructions(
Repl, TLInfo, nullptr,
[&](Value *V) { removeAllAssertingVHReferences(V); });
if (IterHandle != CurValue) {
// If the iterator instruction was recursively deleted, start over at the
// start of the block.
CurInstIterator = BB->begin();
SunkAddrs.clear();
}
resetIteratorIfInvalidatedWhileCalling(CurInstIterator->getParent(), [&]() {
RecursivelyDeleteTriviallyDeadInstructions(
Repl, TLInfo, nullptr,
[&](Value *V) { removeAllAssertingVHReferences(V); });
});
}
++NumMemoryInsts;
return true;