diff options
-rw-r--r-- | llvm/include/llvm/Analysis/MemorySSA.h | 14 | ||||
-rw-r--r-- | llvm/lib/Analysis/MemorySSA.cpp | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/llvm/include/llvm/Analysis/MemorySSA.h b/llvm/include/llvm/Analysis/MemorySSA.h index cace882f60e..93911b7407f 100644 --- a/llvm/include/llvm/Analysis/MemorySSA.h +++ b/llvm/include/llvm/Analysis/MemorySSA.h @@ -93,6 +93,7 @@ #include "llvm/IR/Use.h" #include "llvm/IR/User.h" #include "llvm/IR/Value.h" +#include "llvm/IR/ValueHandle.h" #include "llvm/Pass.h" #include "llvm/Support/Casting.h" #include <algorithm> @@ -217,10 +218,18 @@ protected: : DerivedUser(Type::getVoidTy(C), Vty, nullptr, NumOperands, DeleteValue), Block(BB) {} + // Use deleteValue() to delete a generic MemoryAccess. + ~MemoryAccess() = default; + private: BasicBlock *Block; }; +template <> +struct ilist_alloc_traits<MemoryAccess> { + static void deleteNode(MemoryAccess *MA) { MA->deleteValue(); } +}; + inline raw_ostream &operator<<(raw_ostream &OS, const MemoryAccess &MA) { MA.print(OS); return OS; @@ -270,6 +279,9 @@ protected: setDefiningAccess(DMA); } + // Use deleteValue() to delete a generic MemoryUseOrDef. + ~MemoryUseOrDef() = default; + void setDefiningAccess(MemoryAccess *DMA, bool Optimized = false) { if (!Optimized) { setOperand(0, DMA); @@ -773,7 +785,7 @@ private: // corresponding list is empty. AccessMap PerBlockAccesses; DefsMap PerBlockDefs; - std::unique_ptr<MemoryAccess> LiveOnEntryDef; + std::unique_ptr<MemoryAccess, ValueDeleter> LiveOnEntryDef; // Domination mappings // Note that the numbering is local to a block, even though the map is diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp index 584e8855096..77126344c60 100644 --- a/llvm/lib/Analysis/MemorySSA.cpp +++ b/llvm/lib/Analysis/MemorySSA.cpp @@ -1304,9 +1304,8 @@ void MemorySSA::buildMemorySSA() { // semantics do *not* imply that something with no immediate uses can simply // be removed. BasicBlock &StartingPoint = F.getEntryBlock(); - LiveOnEntryDef = - llvm::make_unique<MemoryDef>(F.getContext(), nullptr, nullptr, - &StartingPoint, NextID++); + LiveOnEntryDef.reset(new MemoryDef(F.getContext(), nullptr, nullptr, + &StartingPoint, NextID++)); DenseMap<const BasicBlock *, unsigned int> BBNumbers; unsigned NextBBNum = 0; |