[PATCH] D50650: [MemorySSA] Add API to update an incoming block into a MemoryPhi.
Alina Sbirlea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 13 10:44:06 PDT 2018
asbirlea created this revision.
asbirlea added a reviewer: george.burgess.iv.
Herald added subscribers: Prazek, jlebar, sanjoy.
Add an API to update the incoming block into a MemoryPhi when a block predecessors changes.
The use case is when splitting blocks. This patch unblocks https://reviews.llvm.org/D45300.
Repository:
rL LLVM
https://reviews.llvm.org/D50650
Files:
include/llvm/Analysis/MemorySSAUpdater.h
lib/Analysis/MemorySSAUpdater.cpp
Index: lib/Analysis/MemorySSAUpdater.cpp
===================================================================
--- lib/Analysis/MemorySSAUpdater.cpp
+++ lib/Analysis/MemorySSAUpdater.cpp
@@ -392,6 +392,16 @@
}
}
+void MemorySSAUpdater::replacePhiIncomingBlock(BasicBlock *BB,
+ BasicBlock *ToReplace,
+ BasicBlock *ReplaceWith) {
+ if (MemoryPhi *MPhi = MSSA->getMemoryAccess(BB)) {
+ unsigned I = MPhi->getBasicBlockIndex(ToReplace);
+ assert((I >= 0) && "MemoryPhi position out of bounds");
+ MPhi->setIncomingBlock(I, ReplaceWith);
+ }
+}
+
// Move What before Where in the MemorySSA IR.
template <class WhereType>
void MemorySSAUpdater::moveTo(MemoryUseOrDef *What, BasicBlock *BB,
Index: include/llvm/Analysis/MemorySSAUpdater.h
===================================================================
--- include/llvm/Analysis/MemorySSAUpdater.h
+++ include/llvm/Analysis/MemorySSAUpdater.h
@@ -132,7 +132,11 @@
void
wireOldPredecessorsToNewImmediatePredecessor(BasicBlock *Old, BasicBlock *New,
ArrayRef<BasicBlock *> Preds);
-
+ /// `ToReplace` used to be a predecessor of BB. `ReplaceWith` is the new
+ /// predecessor. Update Phi in BB to replace incoming block `ToReplace` with
+ /// `ReplaceWith`.
+ void replacePhiIncomingBlock(BasicBlock *BB, BasicBlock *ToReplace,
+ BasicBlock *ReplaceWith);
// The below are utility functions. Other than creation of accesses to pass
// to insertDef, and removeAccess to remove accesses, you should generally
// not attempt to update memoryssa yourself. It is very non-trivial to get
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50650.160396.patch
Type: text/x-patch
Size: 1736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180813/c1fad53e/attachment.bin>
More information about the llvm-commits
mailing list