[llvm] 9ddb1a4 - [Attributor][FIX] Avoid double free (and useless state copy)

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 08:10:47 PST 2022


Author: Johannes Doerfert
Date: 2022-03-11T10:10:36-06:00
New Revision: 9ddb1a49ac08d8cd66771de56d5c3227d586b579

URL: https://github.com/llvm/llvm-project/commit/9ddb1a49ac08d8cd66771de56d5c3227d586b579
DIFF: https://github.com/llvm/llvm-project/commit/9ddb1a49ac08d8cd66771de56d5c3227d586b579.diff

LOG: [Attributor][FIX] Avoid double free (and useless state copy)

In an attempt to remove the memory leak we introduced a double free.
The problem was that we allowed a plain copy of the state and it was
actually used. The use was useless, so it is gone now. The copy
constructor is gone as well. The move constructor ensures the Accesses
pointers are owned by a single state, I hope.

Reported by: https://lab.llvm.org/buildbot/#/builders/16/builds/25820

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 f712dc912edd0..dae0642fb4d70 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -884,8 +884,9 @@ struct AA::PointerInfo::State : public AbstractState {
   }
 
   State() = default;
-  State(const State &SIS) : AccessBins(SIS.AccessBins) {}
-  State(State &&SIS) : AccessBins(std::move(SIS.AccessBins)) {}
+  State(State &&SIS) : AccessBins(std::move(SIS.AccessBins)) {
+    SIS.AccessBins.clear();
+  }
 
   const State &getAssumed() const { return *this; }
 
@@ -1336,7 +1337,6 @@ struct AAPointerInfoFloating : public AAPointerInfoImpl {
   /// See AbstractAttribute::updateImpl(...).
   ChangeStatus updateImpl(Attributor &A) override {
     using namespace AA::PointerInfo;
-    State S = getState();
     ChangeStatus Changed = ChangeStatus::UNCHANGED;
     Value &AssociatedValue = getAssociatedValue();
 


        


More information about the llvm-commits mailing list