#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/KnowledgeRetention.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/Support/Allocator.h"
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
namespace llvm {
: 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).
///
/// 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.
///
/// 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) {
#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) \