Skip to content

Commit

Permalink
[Attributor][FIX] Avoid double free (and useless state copy)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jdoerfert committed Mar 11, 2022
1 parent 30c5269 commit 9ddb1a4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Expand Up @@ -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; }

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 9ddb1a4

Please sign in to comment.