[PATCH] D51716: [MemorySSA] Add API to reset optimized for uses of a replaced instruction.
Alina Sbirlea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 6 15:43:17 PDT 2018
asbirlea updated this revision to Diff 164299.
asbirlea added a comment.
Need to bypass geps when traversing users, use worklist.
Adding test in dependent patch.
Repository:
rL LLVM
https://reviews.llvm.org/D51716
Files:
include/llvm/Analysis/MemorySSAUpdater.h
lib/Analysis/MemorySSAUpdater.cpp
Index: lib/Analysis/MemorySSAUpdater.cpp
===================================================================
--- lib/Analysis/MemorySSAUpdater.cpp
+++ lib/Analysis/MemorySSAUpdater.cpp
@@ -607,6 +607,25 @@
}
}
+void MemorySSAUpdater::resetOptimizeUses(const Instruction *I) {
+ SmallVector<const Instruction *, 16> Worklist;
+ for (const auto *Usr : I->users())
+ if (auto *UsrI = dyn_cast<Instruction>(Usr))
+ Worklist.push_back(UsrI);
+
+ for (unsigned It = 0; It < Worklist.size(); ++It) {
+ if (auto *MA = MSSA->getMemoryAccess(Worklist[It])) {
+ auto *MUD = cast<MemoryUseOrDef>(MA);
+ if (MUD->isOptimized())
+ MUD->resetOptimized();
+ } else {
+ for (const auto *Usr : Worklist[It]->users())
+ if (auto *UsrI = dyn_cast<Instruction>(Usr))
+ Worklist.push_back(UsrI);
+ }
+ }
+}
+
MemoryAccess *MemorySSAUpdater::createMemoryAccessInBB(
Instruction *I, MemoryAccess *Definition, const BasicBlock *BB,
MemorySSA::InsertionPlace Point) {
Index: include/llvm/Analysis/MemorySSAUpdater.h
===================================================================
--- include/llvm/Analysis/MemorySSAUpdater.h
+++ include/llvm/Analysis/MemorySSAUpdater.h
@@ -198,6 +198,12 @@
/// deleted after this call.
void removeBlocks(const SmallPtrSetImpl<BasicBlock *> &DeadBlocks);
+ /// Reset optimized for uses of a given instruction, if those uses have
+ /// MemoryAccesses. This should be called when the instruction is about to be
+ /// replaced, since its replacement may change the clobber (e.g., simplify to
+ /// undef).
+ void resetOptimizeUses(const Instruction *I);
+
/// Get handle on MemorySSA.
MemorySSA* getMemorySSA() const { return MSSA; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51716.164299.patch
Type: text/x-patch
Size: 1739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180906/efcc5e1b/attachment.bin>
More information about the llvm-commits
mailing list