[PATCH] D76589: [Attributor][NFC] Use a BumpPtrAllocator to allocate `AbstractAttribute`s
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 23 00:31:06 PDT 2020
jdoerfert created this revision.
jdoerfert added reviewers: lebedev.ri, uenoku, sstefan1, baziotis.
Herald added subscribers: bollu, hiraditya.
Herald added a project: LLVM.
We create a lot of AbstractAttributes and they live as long as
the Attributor does. It seems reasonable to allocate them via a
BumpPtrAllocator owned by the Attributor.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76589
Files:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -7271,6 +7271,16 @@
/// Attributor
/// ----------------------------------------------------------------------------
+Attributor::~Attributor() {
+ // The abstract attributes are allocated via the BumpPtrAllocator Allocator,
+ // thus we cannot delete them. We can, and want to, destruct them though.
+ for (AbstractAttribute *AA : AllAbstractAttributes)
+ AA->~AbstractAttribute();
+
+ for (auto &It : ArgumentReplacementMap)
+ DeleteContainerPointers(It.second);
+}
+
bool Attributor::isAssumedDead(const AbstractAttribute &AA,
const AAIsDead *FnLivenessAA,
bool CheckBBLivenessOnly, DepClassTy DepClass) {
@@ -8833,7 +8843,7 @@
#define SWITCH_PK_CREATE(CLASS, IRP, PK, SUFFIX) \
case IRPosition::PK: \
- AA = new CLASS##SUFFIX(IRP); \
+ AA = new (A.Allocator) CLASS##SUFFIX(IRP); \
break;
#define CREATE_FUNCTION_ABSTRACT_ATTRIBUTE_FOR_POSITION(CLASS) \
Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -111,6 +111,7 @@
#include "llvm/IR/CallSite.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/Support/Allocator.h"
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
namespace llvm {
@@ -688,11 +689,7 @@
: Functions(Functions), InfoCache(InfoCache), CGUpdater(CGUpdater),
DepRecomputeInterval(DepRecomputeInterval), Whitelist(Whitelist) {}
- ~Attributor() {
- DeleteContainerPointers(AllAbstractAttributes);
- for (auto &It : ArgumentReplacementMap)
- DeleteContainerPointers(It.second);
- }
+ ~Attributor();
/// Run the analyses until a fixpoint is reached or enforced (timeout).
///
@@ -1061,6 +1058,9 @@
/// Return the data layout associated with the anchor scope.
const DataLayout &getDataLayout() const { return InfoCache.DL; }
+ /// The allocator used to allocate memory, e.g. for `AbstractAttribute`s.
+ BumpPtrAllocator Allocator;
+
private:
/// Check \p Pred on all call sites of \p Fn.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76589.251952.patch
Type: text/x-patch
Size: 2594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200323/9e3d057f/attachment-0001.bin>
More information about the llvm-commits
mailing list