/// instance down in the abstract attributes.
struct InformationCache {
InformationCache(const Module &M, AnalysisGetter &AG,
- SetVector<Function *> *CGSCC)
- : DL(M.getDataLayout()),
+ BumpPtrAllocator &Allocator, SetVector<Function *> *CGSCC)
+ : DL(M.getDataLayout()), Allocator(Allocator),
Explorer(
/* ExploreInterBlock */ true, /* ExploreCFGForward */ true,
/* ExploreCFGBackward */ true,
AG(AG), CGSCC(CGSCC) {}
~InformationCache() {
- DeleteContainerSeconds(FuncInfoMap);
+ // The FunctionInfo objects are allocated via a BumpPtrAllocator, we call
+ // the destructor manually.
+ for (auto &It : FuncInfoMap)
+ It.getSecond()->~FunctionInfo();
}
/// A map type from opcodes to instructions with this opcode.
FunctionInfo &getFunctionInfo(const Function &F) {
FunctionInfo *&FI = FuncInfoMap[&F];
if (!FI) {
- FI = new FunctionInfo();
+ FI = new (Allocator) FunctionInfo();
initializeInformationCache(F, *FI);
}
return *FI;
/// The datalayout used in the module.
const DataLayout &DL;
+ /// The allocator used to allocate memory, e.g. for `FunctionInfo`s.
+ BumpPtrAllocator &Allocator;
+
/// MustBeExecutedContextExplorer
MustBeExecutedContextExplorer Explorer;
Attributor(SetVector<Function *> &Functions, InformationCache &InfoCache,
CallGraphUpdater &CGUpdater, unsigned DepRecomputeInterval,
DenseSet<const char *> *Whitelist = nullptr)
- : Functions(Functions), InfoCache(InfoCache), CGUpdater(CGUpdater),
+ : Allocator(InfoCache.Allocator), Functions(Functions),
+ InfoCache(InfoCache), CGUpdater(CGUpdater),
DepRecomputeInterval(DepRecomputeInterval), Whitelist(Whitelist) {}
~Attributor();
const DataLayout &getDataLayout() const { return InfoCache.DL; }
/// The allocator used to allocate memory, e.g. for `AbstractAttribute`s.
- BumpPtrAllocator Allocator;
+ BumpPtrAllocator &Allocator;
private:
/// Check \p Pred on all call sites of \p Fn.
Functions.insert(&F);
CallGraphUpdater CGUpdater;
- InformationCache InfoCache(M, AG, /* CGSCC */ nullptr);
+ BumpPtrAllocator Allocator;
+ InformationCache InfoCache(M, AG, Allocator, /* CGSCC */ nullptr);
if (runAttributorOnFunctions(InfoCache, Functions, AG, CGUpdater)) {
// FIXME: Think about passes we will preserve and add them here.
return PreservedAnalyses::none();
Module &M = *Functions.back()->getParent();
CallGraphUpdater CGUpdater;
CGUpdater.initialize(CG, C, AM, UR);
- InformationCache InfoCache(M, AG, /* CGSCC */ &Functions);
+ BumpPtrAllocator Allocator;
+ InformationCache InfoCache(M, AG, Allocator, /* CGSCC */ &Functions);
if (runAttributorOnFunctions(InfoCache, Functions, AG, CGUpdater)) {
// FIXME: Think about passes we will preserve and add them here.
return PreservedAnalyses::none();
Functions.insert(&F);
CallGraphUpdater CGUpdater;
- InformationCache InfoCache(M, AG, /* CGSCC */ nullptr);
+ BumpPtrAllocator Allocator;
+ InformationCache InfoCache(M, AG, Allocator, /* CGSCC */ nullptr);
return runAttributorOnFunctions(InfoCache, Functions, AG, CGUpdater);
}
CallGraph &CG = const_cast<CallGraph &>(SCC.getCallGraph());
CGUpdater.initialize(CG, SCC);
Module &M = *Functions.back()->getParent();
- InformationCache InfoCache(M, AG, /* CGSCC */ &Functions);
+ BumpPtrAllocator Allocator;
+ InformationCache InfoCache(M, AG, Allocator, /* CGSCC */ &Functions);
return runAttributorOnFunctions(InfoCache, Functions, AG, CGUpdater);
}