[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 16:13:19 PDT 2018
asbirlea updated this revision to Diff 164314.
asbirlea added a comment.
Avoid duplicates (use set).
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
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------===//
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/IR/DataLayout.h"
@@ -607,6 +608,26 @@
}
}
+void MemorySSAUpdater::resetOptimizeUses(const Instruction *I) {
+ SmallSetVector<const Instruction *, 16> Worklist;
+ for (const auto *Usr : I->users())
+ if (auto *UsrI = dyn_cast<Instruction>(Usr))
+ Worklist.insert(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))
+ if (!Worklist.count(UsrI))
+ Worklist.insert(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.164314.patch
Type: text/x-patch
Size: 2087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180906/b186c09c/attachment.bin>
More information about the llvm-commits
mailing list