Skip to content

Commit

Permalink
[Attributor][FIX] Remove memory leak
Browse files Browse the repository at this point in the history
The leak was introduced when we made things deterministic. It was
reported by the sanitizer buildbot:
 https://lab.llvm.org/buildbot/#/builders/168
  • Loading branch information
jdoerfert committed Mar 11, 2022
1 parent a0d2b0a commit 3570b0c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Expand Up @@ -38,8 +38,8 @@
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/NoFolder.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
Expand Down Expand Up @@ -867,6 +867,12 @@ struct AccessAsInstructionInfo : DenseMapInfo<Instruction *> {
/// A type to track pointer/struct usage and accesses for AAPointerInfo.
struct AA::PointerInfo::State : public AbstractState {

~State() {
// We do not delete the Accesses objects but need to destroy them still.
for (auto &It : AccessBins)
It.second->~Accesses();
}

/// Return the best possible representable state.
static State getBestState(const State &SIS) { return State(); }

Expand Down Expand Up @@ -6423,8 +6429,10 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
Changed = ChangeStatus::CHANGED;
continue;
} else {
if (APAlign->ugt(llvm::Value::MaximumAlignment) || !APAlign->isPowerOf2()) {
LLVM_DEBUG(dbgs() << "[H2S] Invalid allocation alignment: " << APAlign << "\n");
if (APAlign->ugt(llvm::Value::MaximumAlignment) ||
!APAlign->isPowerOf2()) {
LLVM_DEBUG(dbgs() << "[H2S] Invalid allocation alignment: " << APAlign
<< "\n");
AI.Status = AllocationInfo::INVALID;
Changed = ChangeStatus::CHANGED;
continue;
Expand Down

0 comments on commit 3570b0c

Please sign in to comment.