[Attributor][FIX] Avoid memory leakage through InstExclusionSet
authorJohannes Doerfert <johannes@jdoerfert.de>
Wed, 14 Dec 2022 06:57:55 +0000 (22:57 -0800)
committerJohannes Doerfert <johannes@jdoerfert.de>
Wed, 14 Dec 2022 06:58:34 +0000 (22:58 -0800)
llvm/include/llvm/Transforms/IPO/Attributor.h

index 3d622fd..f7c4300 100644 (file)
@@ -1142,6 +1142,10 @@ struct InformationCache {
     // the destructor manually.
     for (auto &It : FuncInfoMap)
       It.getSecond()->~FunctionInfo();
+    // Same is true for the instruction exclusions sets.
+    using AA::InstExclusionSetTy;
+    for (auto *BES : BESets)
+      BES->~InstExclusionSetTy();
   }
 
   /// Apply \p CB to all uses of \p F. If \p LookThroughConstantExprUses is
@@ -1338,7 +1342,7 @@ private:
   SetVector<const Instruction *> AssumeOnlyValues;
 
   /// Cache for block sets to allow reuse.
-  DenseSet<const AA::InstExclusionSetTy *> BESets;
+  DenseSet<AA::InstExclusionSetTy *> BESets;
 
   /// Getters for analysis.
   AnalysisGetter &AG;