[llvm] r326175 - [MemorySSA] Call the correct dtors
George Burgess IV via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 23:24:14 PST 2018
(The added #include was actually meant to go in as a part of r326177. Oops.)
On Mon, Feb 26, 2018 at 10:43 PM, George Burgess IV via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: gbiv
> Date: Mon Feb 26 22:43:19 2018
> New Revision: 326175
>
> URL: http://llvm.org/viewvc/llvm-project?rev=326175&view=rev
> Log:
> [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.
> :)
>
> Modified:
> llvm/trunk/include/llvm/Analysis/MemorySSA.h
> llvm/trunk/lib/Analysis/MemorySSA.cpp
>
> Modified: llvm/trunk/include/llvm/Analysis/MemorySSA.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/
> Analysis/MemorySSA.h?rev=326175&r1=326174&r2=326175&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/Analysis/MemorySSA.h (original)
> +++ llvm/trunk/include/llvm/Analysis/MemorySSA.h Mon Feb 26 22:43:19 2018
> @@ -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
>
> Modified: llvm/trunk/lib/Analysis/MemorySSA.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/
> MemorySSA.cpp?rev=326175&r1=326174&r2=326175&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Analysis/MemorySSA.cpp (original)
> +++ llvm/trunk/lib/Analysis/MemorySSA.cpp Mon Feb 26 22:43:19 2018
> @@ -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;
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180226/cecbe7ec/attachment.html>
More information about the llvm-commits
mailing list