Skip to content

Commit 0dc0d3f

Browse files
committed
LiveIntervals: Use BumpPtrAllocator
1 parent 8039f8e commit 0dc0d3f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

llvm/include/llvm/CodeGen/LiveIntervals.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "llvm/CodeGen/SlotIndexes.h"
3131
#include "llvm/CodeGen/TargetRegisterInfo.h"
3232
#include "llvm/MC/LaneBitmask.h"
33+
#include "llvm/Support/Allocator.h"
3334
#include "llvm/Support/CommandLine.h"
3435
#include "llvm/Support/Compiler.h"
3536
#include "llvm/Support/ErrorHandling.h"
@@ -64,6 +65,8 @@ class LiveIntervals {
6465
MachineDominatorTree *DomTree = nullptr;
6566
std::unique_ptr<LiveIntervalCalc> LICalc;
6667

68+
BumpPtrAllocator Allocator;
69+
6770
/// Special pool allocator for VNInfo's (LiveInterval val#).
6871
VNInfo::Allocator VNInfoAllocator;
6972

@@ -170,7 +173,7 @@ class LiveIntervals {
170173
/// Interval removal.
171174
void removeInterval(Register Reg) {
172175
auto &Interval = VirtRegIntervals[Reg];
173-
delete Interval;
176+
Allocator.Deallocate(Interval);
174177
Interval = nullptr;
175178
}
176179

@@ -416,7 +419,8 @@ class LiveIntervals {
416419
if (!LR) {
417420
// Compute missing ranges on demand.
418421
// Use segment set to speed-up initial computation of the live range.
419-
RegUnitRanges[Unit] = LR = new LiveRange(UseSegmentSetForPhysRegs);
422+
RegUnitRanges[Unit] = LR = new (Allocator.Allocate<LiveRange>())
423+
LiveRange(UseSegmentSetForPhysRegs);
420424
computeRegUnitRange(*LR, Unit);
421425
}
422426
return *LR;
@@ -433,7 +437,7 @@ class LiveIntervals {
433437
/// Remove computed live range for register unit \p Unit. Subsequent uses
434438
/// should rely on on-demand recomputation.
435439
void removeRegUnit(unsigned Unit) {
436-
delete RegUnitRanges[Unit];
440+
Allocator.Deallocate(RegUnitRanges[Unit]);
437441
RegUnitRanges[Unit] = nullptr;
438442
}
439443

@@ -481,7 +485,7 @@ class LiveIntervals {
481485
bool computeDeadValues(LiveInterval &LI,
482486
SmallVectorImpl<MachineInstr *> *dead);
483487

484-
static LiveInterval *createInterval(Register Reg);
488+
LiveInterval *createInterval(Register Reg);
485489

486490
void printInstrs(raw_ostream &O) const;
487491
void dumpInstrs() const;

llvm/lib/CodeGen/LiveIntervals.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ bool LiveIntervals::invalidate(
144144
void LiveIntervals::clear() {
145145
// Free the live intervals themselves.
146146
for (unsigned i = 0, e = VirtRegIntervals.size(); i != e; ++i)
147-
delete VirtRegIntervals[Register::index2VirtReg(i)];
147+
Allocator.Deallocate(VirtRegIntervals[Register::index2VirtReg(i)]);
148148
VirtRegIntervals.clear();
149149
RegMaskSlots.clear();
150150
RegMaskBits.clear();
151151
RegMaskBlocks.clear();
152152

153153
for (LiveRange *LR : RegUnitRanges)
154-
delete LR;
154+
Allocator.Deallocate(LR);
155155
RegUnitRanges.clear();
156156

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

223223
LiveInterval *LiveIntervals::createInterval(Register reg) {
224224
float Weight = reg.isPhysical() ? huge_valf : 0.0F;
225-
return new LiveInterval(reg, Weight);
225+
return new (Allocator.Allocate<LiveInterval>()) LiveInterval(reg, Weight);
226226
}
227227

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

0 commit comments

Comments
 (0)