Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions llvm/include/llvm/CodeGen/LiveIntervals.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/MC/LaneBitmask.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
Expand Down Expand Up @@ -64,6 +65,15 @@ class LiveIntervals {
MachineDominatorTree *DomTree = nullptr;
std::unique_ptr<LiveIntervalCalc> LICalc;

// Allocator for SubRanges.
BumpPtrAllocator Allocator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment saying what this is used for?


// Allocator for VirtRegIntervals
SpecificBumpPtrAllocator<LiveInterval> LIAllocator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need this for LiveRange as well, as it contains vectors.


// Allocator for RegUnitRanges
SpecificBumpPtrAllocator<LiveRange> LRAllocator;

/// Special pool allocator for VNInfo's (LiveInterval val#).
VNInfo::Allocator VNInfoAllocator;

Expand Down Expand Up @@ -170,7 +180,7 @@ class LiveIntervals {
/// Interval removal.
void removeInterval(Register Reg) {
auto &Interval = VirtRegIntervals[Reg];
delete Interval;
// FIXME: SpecificBumpPtrAllocator missing deallocate for asan poisoning
Interval = nullptr;
}

Expand Down Expand Up @@ -416,7 +426,8 @@ class LiveIntervals {
if (!LR) {
// Compute missing ranges on demand.
// Use segment set to speed-up initial computation of the live range.
RegUnitRanges[Unit] = LR = new LiveRange(UseSegmentSetForPhysRegs);
RegUnitRanges[Unit] = LR =
new (LRAllocator.Allocate()) LiveRange(UseSegmentSetForPhysRegs);
computeRegUnitRange(*LR, Unit);
}
return *LR;
Expand All @@ -433,7 +444,7 @@ class LiveIntervals {
/// Remove computed live range for register unit \p Unit. Subsequent uses
/// should rely on on-demand recomputation.
void removeRegUnit(unsigned Unit) {
delete RegUnitRanges[Unit];
Allocator.Deallocate(RegUnitRanges[Unit]);
RegUnitRanges[Unit] = nullptr;
}

Expand Down Expand Up @@ -481,7 +492,7 @@ class LiveIntervals {
bool computeDeadValues(LiveInterval &LI,
SmallVectorImpl<MachineInstr *> *dead);

static LiveInterval *createInterval(Register Reg);
LiveInterval *createInterval(Register Reg);

void printInstrs(raw_ostream &O) const;
void dumpInstrs() const;
Expand Down
16 changes: 8 additions & 8 deletions llvm/lib/CodeGen/LiveIntervals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,17 @@ bool LiveIntervals::invalidate(
}

void LiveIntervals::clear() {
// Free the live intervals themselves.
for (unsigned i = 0, e = VirtRegIntervals.size(); i != e; ++i)
delete VirtRegIntervals[Register::index2VirtReg(i)];
VirtRegIntervals.clear();
RegMaskSlots.clear();
RegMaskBits.clear();
RegMaskBlocks.clear();

for (LiveRange *LR : RegUnitRanges)
delete LR;
LRAllocator.DestroyAll();
RegUnitRanges.clear();

// Free the live intervals themselves.
LIAllocator.DestroyAll();
VirtRegIntervals.clear();

// Release VNInfo memory regions, VNInfo objects don't need to be dtor'd.
VNInfoAllocator.Reset();
}
Expand Down Expand Up @@ -222,7 +221,7 @@ LLVM_DUMP_METHOD void LiveIntervals::dump() const { print(dbgs()); }

LiveInterval *LiveIntervals::createInterval(Register reg) {
float Weight = reg.isPhysical() ? huge_valf : 0.0F;
return new LiveInterval(reg, Weight);
return new (LIAllocator.Allocate()) LiveInterval(reg, Weight);
}

/// Compute the live interval of a virtual register, based on defs and uses.
Expand Down Expand Up @@ -374,7 +373,8 @@ void LiveIntervals::computeLiveInRegUnits() {
LiveRange *LR = RegUnitRanges[Unit];
if (!LR) {
// Use segment set to speed-up initial computation of the live range.
LR = RegUnitRanges[Unit] = new LiveRange(UseSegmentSetForPhysRegs);
LR = RegUnitRanges[Unit] = new (Allocator.Allocate<LiveRange>())
LiveRange(UseSegmentSetForPhysRegs);
NewRanges.push_back(Unit);
}
VNInfo *VNI = LR->createDeadDef(Begin, getVNInfoAllocator());
Expand Down