From 2e7e2994a94efad7fde5547d4e493e28b3b660a3 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Sat, 10 Jul 2021 18:53:37 -0500 Subject: [PATCH] [Attributor][FIX] Destroy bump allocator objects to avoid leaks AllocationInfo and DeallocationInfo objects themselves are allocated with the Attributor bump allocator and do not need to be deallocated. That said, the sets in AllocationInfo and DeallocationInfo need to be destroyed to avoid memory leaks. --- llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 11c1bcd..3d7b12f 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -4907,6 +4907,15 @@ struct AAHeapToStackFunction final : public AAHeapToStack { AAHeapToStackFunction(const IRPosition &IRP, Attributor &A) : AAHeapToStack(IRP, A) {} + ~AAHeapToStackFunction() { + // Ensure we call the destructor so we release any memory allocated in the + // sets. + for (auto &It : AllocationInfos) + It.getSecond()->~AllocationInfo(); + for (auto &It : DeallocationInfos) + It.getSecond()->~DeallocationInfo(); + } + void initialize(Attributor &A) override { AAHeapToStack::initialize(A); @@ -7158,7 +7167,7 @@ struct AAValueConstantRangeImpl : AAValueConstantRange { const DominatorTree *DT = InfoCache.getAnalysisResultForFunction( *I->getFunction()); - return DT && DT->dominates(I, CtxI); + return DT && DT->dominates(I, CtxI); } return true; -- 2.7.4