summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-11-20 13:44:51 -0800
committerAlina Sbirlea <asbirlea@google.com>2019-11-20 16:36:52 -0800
commitda4baa2a6c966154e19964fdced1119ed2f4d6ee (patch)
treed082c26fab0399dda855cbdff71c28d6981b03a7 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
parent049043b598ef5b12a5894c0c22db8608be70f517 (diff)
downloadbcm5719-llvm-da4baa2a6c966154e19964fdced1119ed2f4d6ee.tar.gz
bcm5719-llvm-da4baa2a6c966154e19964fdced1119ed2f4d6ee.zip
[MemorySSA] Update analysis when the terminator is a memory instruction.
Update MemorySSA when moving the terminator instruction, as that may be a memory touching instruction. Resolves PR44029.
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/BasicBlockUtils.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index d85cc40c372..31eaf260735 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -247,7 +247,7 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
Instruction *STI = BB->getTerminator();
Instruction *Start = &*BB->begin();
// If there's nothing to move, mark the starting instruction as the last
- // instruction in the block.
+ // instruction in the block. Terminator instruction is handled separately.
if (Start == STI)
Start = PTI;
@@ -274,6 +274,12 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
// Move terminator instruction.
PredBB->getInstList().splice(PredBB->end(), BB->getInstList());
+
+ // Terminator may be a memory accessing instruction too.
+ if (MSSAU)
+ if (MemoryUseOrDef *MUD = cast_or_null<MemoryUseOrDef>(
+ MSSAU->getMemorySSA()->getMemoryAccess(PredBB->getTerminator())))
+ MSSAU->moveToPlace(MUD, PredBB, MemorySSA::End);
}
// Add unreachable to now empty BB.
new UnreachableInst(BB->getContext(), BB);
OpenPOWER on IntegriCloud