[llvm] 2e7e299 - [Attributor][FIX] Destroy bump allocator objects to avoid leaks

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 10 16:56:28 PDT 2021


Author: Johannes Doerfert
Date: 2021-07-10T18:53:37-05:00
New Revision: 2e7e2994a94efad7fde5547d4e493e28b3b660a3

URL: https://github.com/llvm/llvm-project/commit/2e7e2994a94efad7fde5547d4e493e28b3b660a3
DIFF: https://github.com/llvm/llvm-project/commit/2e7e2994a94efad7fde5547d4e493e28b3b660a3.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 11c1bcdeb338..3d7b12fbeda6 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<DominatorTreeAnalysis>(
               *I->getFunction());
-       return DT && DT->dominates(I, CtxI);
+      return DT && DT->dominates(I, CtxI);
     }
 
     return true;


        


More information about the llvm-commits mailing list