summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2018-09-07 21:14:48 +0000
committerAlina Sbirlea <asbirlea@google.com>2018-09-07 21:14:48 +0000
commitf98c2c5e6d65fb2a0194fd3ea9f52d793035f63c (patch)
treeb0690a03c5533133aa2f605d9b5e39b2d87aa881 /llvm/lib/Analysis
parentc1416b60f2114d4237643c2aef6eddbf53c42d5b (diff)
downloadbcm5719-llvm-f98c2c5e6d65fb2a0194fd3ea9f52d793035f63c.tar.gz
bcm5719-llvm-f98c2c5e6d65fb2a0194fd3ea9f52d793035f63c.zip
[MemorySSA] Update MemoryPhi wiring for block splitting to consider if identical edges were merged.
Summary: Block splitting is done with either identical edges being merged, or not. Only critical edges can be split without merging identical edges based on an option. Teach the memoryssa updater to take this into account: for the same edge between two blocks only move one entry from the Phi in Old to the new Phi in New. Reviewers: george.burgess.iv Subscribers: sanjoy, jlebar, Prazek, llvm-commits Differential Revision: https://reviews.llvm.org/D51563 llvm-svn: 341709
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/MemorySSAUpdater.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index abd67cc2e93..a889b607d21 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -498,7 +498,8 @@ static MemoryAccess *onlySingleValue(MemoryPhi *MP) {
}
void MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor(
- BasicBlock *Old, BasicBlock *New, ArrayRef<BasicBlock *> Preds) {
+ BasicBlock *Old, BasicBlock *New, ArrayRef<BasicBlock *> Preds,
+ bool IdenticalEdgesWereMerged) {
assert(!MSSA->getWritableBlockAccesses(New) &&
"Access list should be null for a new block.");
MemoryPhi *Phi = MSSA->getMemoryAccess(Old);
@@ -513,9 +514,17 @@ void MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor(
"new immediate predecessor.");
MemoryPhi *NewPhi = MSSA->createMemoryPhi(New);
SmallPtrSet<BasicBlock *, 16> PredsSet(Preds.begin(), Preds.end());
+ // Currently only support the case of removing a single incoming edge when
+ // identical edges were not merged.
+ if (!IdenticalEdgesWereMerged)
+ assert(PredsSet.size() == Preds.size() &&
+ "If identical edges were not merged, we cannot have duplicate "
+ "blocks in the predecessors");
Phi->unorderedDeleteIncomingIf([&](MemoryAccess *MA, BasicBlock *B) {
if (PredsSet.count(B)) {
NewPhi->addIncoming(MA, B);
+ if (!IdenticalEdgesWereMerged)
+ PredsSet.erase(B);
return true;
}
return false;
OpenPOWER on IntegriCloud