[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
This commit is contained in:
George Burgess IV 2018-02-27 06:43:19 +00:00
parent 13c7f86c5f
commit f0bdcb7452
2 changed files with 15 additions and 4 deletions

View File

@ -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

View File

@ -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;