Use yet another allocator for LiveRanges
Not sure it's worth it for these, there should never be all that
many. We could pre-allocate the maximum size up front.
diff --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index 7cee939..4a4d53e 100644
--- a/llvm/include/llvm/CodeGen/LiveIntervals.h
+++ b/llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -65,12 +65,15 @@
MachineDominatorTree *DomTree = nullptr;
std::unique_ptr<LiveIntervalCalc> LICalc;
- // Allocator for RegUnitRanges and SubRanges.
+ // Allocator for SubRanges.
BumpPtrAllocator Allocator;
// Allocator for VirtRegIntervals
SpecificBumpPtrAllocator<LiveInterval> LIAllocator;
+ // Allocator for RegUnitRanges
+ SpecificBumpPtrAllocator<LiveRange> LRAllocator;
+
/// Special pool allocator for VNInfo's (LiveInterval val#).
VNInfo::Allocator VNInfoAllocator;
@@ -423,8 +426,8 @@
if (!LR) {
// Compute missing ranges on demand.
// Use segment set to speed-up initial computation of the live range.
- RegUnitRanges[Unit] = LR = new (Allocator.Allocate<LiveRange>())
- LiveRange(UseSegmentSetForPhysRegs);
+ RegUnitRanges[Unit] = LR =
+ new (LRAllocator.Allocate()) LiveRange(UseSegmentSetForPhysRegs);
computeRegUnitRange(*LR, Unit);
}
return *LR;
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index fd5cc38..2b46e4e 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -146,8 +146,7 @@
RegMaskBits.clear();
RegMaskBlocks.clear();
- for (LiveRange *LR : RegUnitRanges)
- Allocator.Deallocate(LR);
+ LRAllocator.DestroyAll();
RegUnitRanges.clear();
// Free the live intervals themselves.