diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2022-05-14 11:43:05 +0000 |
commit | 349cc55c9796c4596a5b9904cd3281af295f878f (patch) | |
tree | 410c5a785075730a35f1272ca6a7adf72222ad03 /contrib/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp | |
parent | cb2ae6163174b90e999326ecec3699ee093a5d43 (diff) | |
parent | c0981da47d5696fe36474fcf86b4ce03ae3ff818 (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/contrib/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp b/contrib/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp index 616864f360bf..9c841883de6d 100644 --- a/contrib/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/contrib/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -296,9 +296,8 @@ static void setMemoryPhiValueForBlock(MemoryPhi *MP, const BasicBlock *BB, assert(i != -1 && "Should have found the basic block in the phi"); // We can't just compare i against getNumOperands since one is signed and the // other not. So use it to index into the block iterator. - for (auto BBIter = MP->block_begin() + i; BBIter != MP->block_end(); - ++BBIter) { - if (*BBIter != BB) + for (const BasicBlock *BlockBB : llvm::drop_begin(MP->blocks(), i)) { + if (BlockBB != BB) break; MP->setIncomingValue(i, NewDef); ++i; @@ -491,8 +490,7 @@ void MemorySSAUpdater::fixupDefs(const SmallVectorImpl<WeakVH> &Vars) { } while (!Worklist.empty()) { - const BasicBlock *FixupBlock = Worklist.back(); - Worklist.pop_back(); + const BasicBlock *FixupBlock = Worklist.pop_back_val(); // Get the first def in the block that isn't a phi node. if (auto *Defs = MSSA->getWritableBlockDefs(FixupBlock)) { @@ -822,25 +820,30 @@ void MemorySSAUpdater::applyUpdates(ArrayRef<CFGUpdate> Updates, } if (!DeleteUpdates.empty()) { - if (!UpdateDT) { - SmallVector<CFGUpdate, 0> Empty; - // Deletes are reversed applied, because this CFGView is pretending the - // deletes did not happen yet, hence the edges still exist. - DT.applyUpdates(Empty, RevDeleteUpdates); + if (!InsertUpdates.empty()) { + if (!UpdateDT) { + SmallVector<CFGUpdate, 0> Empty; + // Deletes are reversed applied, because this CFGView is pretending the + // deletes did not happen yet, hence the edges still exist. + DT.applyUpdates(Empty, RevDeleteUpdates); + } else { + // Apply all updates, with the RevDeleteUpdates as PostCFGView. + DT.applyUpdates(Updates, RevDeleteUpdates); + } + + // Note: the MSSA update below doesn't distinguish between a GD with + // (RevDelete,false) and (Delete, true), but this matters for the DT + // updates above; for "children" purposes they are equivalent; but the + // updates themselves convey the desired update, used inside DT only. + GraphDiff<BasicBlock *> GD(RevDeleteUpdates); + applyInsertUpdates(InsertUpdates, DT, &GD); + // Update DT to redelete edges; this matches the real CFG so we can + // perform the standard update without a postview of the CFG. + DT.applyUpdates(DeleteUpdates); } else { - // Apply all updates, with the RevDeleteUpdates as PostCFGView. - DT.applyUpdates(Updates, RevDeleteUpdates); + if (UpdateDT) + DT.applyUpdates(DeleteUpdates); } - - // Note: the MSSA update below doesn't distinguish between a GD with - // (RevDelete,false) and (Delete, true), but this matters for the DT - // updates above; for "children" purposes they are equivalent; but the - // updates themselves convey the desired update, used inside DT only. - GraphDiff<BasicBlock *> GD(RevDeleteUpdates); - applyInsertUpdates(InsertUpdates, DT, &GD); - // Update DT to redelete edges; this matches the real CFG so we can perform - // the standard update without a postview of the CFG. - DT.applyUpdates(DeleteUpdates); } else { if (UpdateDT) DT.applyUpdates(Updates); @@ -1131,11 +1134,7 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef<CFGUpdate> Updates, if (auto DefsList = MSSA->getWritableBlockDefs(BlockWithDefsToReplace)) { for (auto &DefToReplaceUses : *DefsList) { BasicBlock *DominatingBlock = DefToReplaceUses.getBlock(); - Value::use_iterator UI = DefToReplaceUses.use_begin(), - E = DefToReplaceUses.use_end(); - for (; UI != E;) { - Use &U = *UI; - ++UI; + for (Use &U : llvm::make_early_inc_range(DefToReplaceUses.uses())) { MemoryAccess *Usr = cast<MemoryAccess>(U.getUser()); if (MemoryPhi *UsrPhi = dyn_cast<MemoryPhi>(Usr)) { BasicBlock *DominatedBlock = UsrPhi->getIncomingBlock(U); |