diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/Analysis/MemorySSAUpdater.cpp | |
parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
download | src-344a3780b2e33f6ca763666c380202b18aab72a3.tar.gz src-344a3780b2e33f6ca763666c380202b18aab72a3.zip |
Vendor import of llvm-project main 88e66fa60ae5, the last commit beforevendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
the upstream release/13.x branch was created.
Diffstat (limited to 'llvm/lib/Analysis/MemorySSAUpdater.cpp')
-rw-r--r-- | llvm/lib/Analysis/MemorySSAUpdater.cpp | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index 99fa58b8872a..616864f360bf 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -363,14 +363,11 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) { // place, compute IDF and place phis. SmallPtrSet<BasicBlock *, 2> DefiningBlocks; - // If this is the last Def in the block, also compute IDF based on MD, since - // this may a new Def added, and we may need additional Phis. - auto Iter = MD->getDefsIterator(); - ++Iter; - auto IterEnd = MSSA->getBlockDefs(MD->getBlock())->end(); - if (Iter == IterEnd) - DefiningBlocks.insert(MD->getBlock()); - + // If this is the last Def in the block, we may need additional Phis. + // Compute IDF in all cases, as renaming needs to be done even when MD is + // not the last access, because it can introduce a new access past which a + // previous access was optimized; that access needs to be reoptimized. + DefiningBlocks.insert(MD->getBlock()); for (const auto &VH : InsertedPHIs) if (const auto *RealPHI = cast_or_null<MemoryPhi>(VH)) DefiningBlocks.insert(RealPHI->getBlock()); @@ -1395,11 +1392,9 @@ void MemorySSAUpdater::removeBlocks( MemorySSA::AccessList *Acc = MSSA->getWritableBlockAccesses(BB); if (!Acc) continue; - for (auto AB = Acc->begin(), AE = Acc->end(); AB != AE;) { - MemoryAccess *MA = &*AB; - ++AB; - MSSA->removeFromLookups(MA); - MSSA->removeFromLists(MA); + for (MemoryAccess &MA : llvm::make_early_inc_range(*Acc)) { + MSSA->removeFromLookups(&MA); + MSSA->removeFromLists(&MA); } } } @@ -1431,22 +1426,6 @@ void MemorySSAUpdater::changeToUnreachable(const Instruction *I) { tryRemoveTrivialPhis(UpdatedPHIs); } -void MemorySSAUpdater::changeCondBranchToUnconditionalTo(const BranchInst *BI, - const BasicBlock *To) { - const BasicBlock *BB = BI->getParent(); - SmallVector<WeakVH, 16> UpdatedPHIs; - for (const BasicBlock *Succ : successors(BB)) { - removeDuplicatePhiEdgesBetween(BB, Succ); - if (Succ != To) - if (auto *MPhi = MSSA->getMemoryAccess(Succ)) { - MPhi->unorderedDeleteIncomingBlock(BB); - UpdatedPHIs.push_back(MPhi); - } - } - // Optimize trivial phis. - tryRemoveTrivialPhis(UpdatedPHIs); -} - MemoryAccess *MemorySSAUpdater::createMemoryAccessInBB( Instruction *I, MemoryAccess *Definition, const BasicBlock *BB, MemorySSA::InsertionPlace Point) { |