summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2018-02-27 06:43:19 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2018-02-27 06:43:19 +0000
commit612cf21ec7ae21fa294234c583aa7888e3ae410d (patch)
treef7c7d7b7d454dd2cb0d3990daa6f951c47bfcf1b /llvm
parent1137cde9fe779e8169ba54f334869f5a7f7e5061 (diff)
downloadbcm5719-llvm-612cf21ec7ae21fa294234c583aa7888e3ae410d.tar.gz
bcm5719-llvm-612cf21ec7ae21fa294234c583aa7888e3ae410d.zip
[MemorySSA] Call the correct dtors
It appears that there were many cases where we were directly (through templates) calling the dtor of MemoryAccess, which is conceptually an abstract class. This hasn't been a problem, since the data members of all of the subclasses of MemoryAccess have been POD. I'm planning on changing that. :) llvm-svn: 326175
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Analysis/MemorySSA.h14
-rw-r--r--llvm/lib/Analysis/MemorySSA.cpp5
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;
OpenPOWER on IntegriCloud