1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +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 // If we have no uses, recursively delete the value and all dead instructions
// using it. // using it.
if (Repl->use_empty()) { if (Repl->use_empty()) {
// This can cause recursive deletion, which can invalidate our iterator. resetIteratorIfInvalidatedWhileCalling(CurInstIterator->getParent(), [&]() {
// Use a WeakTrackingVH to hold onto it in case this happens.
Value *CurValue = &*CurInstIterator;
WeakTrackingVH IterHandle(CurValue);
BasicBlock *BB = CurInstIterator->getParent();
RecursivelyDeleteTriviallyDeadInstructions( RecursivelyDeleteTriviallyDeadInstructions(
Repl, TLInfo, nullptr, Repl, TLInfo, nullptr,
[&](Value *V) { removeAllAssertingVHReferences(V); }); [&](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();
}
} }
++NumMemoryInsts; ++NumMemoryInsts;
return true; return true;