Skip to content

Commit 81d263d

Browse files
committed
Use SpecificBumpPtrAllocator for LiveInterval
I didn't realize we used a singly linked list for storing subranges, but that seems bad. I didn't realize we used a singly linked list for storing subranges. That seems bad and we should probably switch this to an array
1 parent 0dc0d3f commit 81d263d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

llvm/include/llvm/CodeGen/LiveIntervals.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ class LiveIntervals {
6565
MachineDominatorTree *DomTree = nullptr;
6666
std::unique_ptr<LiveIntervalCalc> LICalc;
6767

68+
// Allocator for RegUnitRanges and SubRanges.
6869
BumpPtrAllocator Allocator;
6970

71+
// Allocator for VirtRegIntervals
72+
SpecificBumpPtrAllocator<LiveInterval> LIAllocator;
73+
7074
/// Special pool allocator for VNInfo's (LiveInterval val#).
7175
VNInfo::Allocator VNInfoAllocator;
7276

@@ -173,7 +177,7 @@ class LiveIntervals {
173177
/// Interval removal.
174178
void removeInterval(Register Reg) {
175179
auto &Interval = VirtRegIntervals[Reg];
176-
Allocator.Deallocate(Interval);
180+
// FIXME: SpecificBumpPtrAllocator missing deallocate for asan poisoning
177181
Interval = nullptr;
178182
}
179183

llvm/lib/CodeGen/LiveIntervals.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ bool LiveIntervals::invalidate(
142142
}
143143

144144
void LiveIntervals::clear() {
145-
// Free the live intervals themselves.
146-
for (unsigned i = 0, e = VirtRegIntervals.size(); i != e; ++i)
147-
Allocator.Deallocate(VirtRegIntervals[Register::index2VirtReg(i)]);
148-
VirtRegIntervals.clear();
149145
RegMaskSlots.clear();
150146
RegMaskBits.clear();
151147
RegMaskBlocks.clear();
@@ -154,6 +150,10 @@ void LiveIntervals::clear() {
154150
Allocator.Deallocate(LR);
155151
RegUnitRanges.clear();
156152

153+
// Free the live intervals themselves.
154+
LIAllocator.DestroyAll();
155+
VirtRegIntervals.clear();
156+
157157
// Release VNInfo memory regions, VNInfo objects don't need to be dtor'd.
158158
VNInfoAllocator.Reset();
159159
}
@@ -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 (Allocator.Allocate<LiveInterval>()) LiveInterval(reg, Weight);
225+
return new (LIAllocator.Allocate()) LiveInterval(reg, Weight);
226226
}
227227

228228
/// Compute the live interval of a virtual register, based on defs and uses.

0 commit comments

Comments
 (0)