diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-03-30 20:16:45 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-03-30 20:16:45 +0000 |
commit | 991de14dd62dcbab4b31357ae22dc5b053ba50a0 (patch) | |
tree | bda68de401067e89361cd37e175d087fe0b3e6f1 /lib | |
parent | 820580dfa9ed3e70d3eda06138a59fd903f61b7a (diff) | |
download | external_llvm-991de14dd62dcbab4b31357ae22dc5b053ba50a0.zip external_llvm-991de14dd62dcbab4b31357ae22dc5b053ba50a0.tar.gz external_llvm-991de14dd62dcbab4b31357ae22dc5b053ba50a0.tar.bz2 |
Introduce SpecificBumpPtrAllocator, a wrapper for BumpPtrAllocator which allows
only a single type of object to be allocated. Use it to make VNInfo destruction
typesafe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/LiveInterval.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/LiveStackAnalysis.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/PreAllocSplitting.cpp | 2 | ||||
-rw-r--r-- | lib/Support/Allocator.cpp | 15 |
5 files changed, 6 insertions, 26 deletions
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index 465b306..025ad05 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/lib/CodeGen/LiveInterval.cpp @@ -591,7 +591,7 @@ void LiveInterval::MergeValueInAsValue( /// used with an unknown definition value. void LiveInterval::MergeInClobberRanges(LiveIntervals &li_, const LiveInterval &Clobbers, - BumpPtrAllocator &VNInfoAllocator) { + VNInfo::Allocator &VNInfoAllocator) { if (Clobbers.empty()) return; DenseMap<VNInfo*, VNInfo*> ValNoMaps; @@ -658,7 +658,7 @@ void LiveInterval::MergeInClobberRanges(LiveIntervals &li_, void LiveInterval::MergeInClobberRange(LiveIntervals &li_, SlotIndex Start, SlotIndex End, - BumpPtrAllocator &VNInfoAllocator) { + VNInfo::Allocator &VNInfoAllocator) { // Find a value # to use for the clobber ranges. If there is already a value# // for unknown values, use it. VNInfo *ClobberValNo = @@ -753,7 +753,7 @@ VNInfo* LiveInterval::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) { void LiveInterval::Copy(const LiveInterval &RHS, MachineRegisterInfo *MRI, - BumpPtrAllocator &VNInfoAllocator) { + VNInfo::Allocator &VNInfoAllocator) { ranges.clear(); valnos.clear(); std::pair<unsigned, unsigned> Hint = MRI->getRegAllocationHint(RHS.reg); diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 53366b9..23cff07 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -82,11 +82,6 @@ void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const { MachineFunctionPass::getAnalysisUsage(AU); } -static void VNInfoDTor(void* Ptr) -{ - reinterpret_cast<VNInfo*>(Ptr)->~VNInfo(); -} - void LiveIntervals::releaseMemory() { // Free the live intervals themselves. for (DenseMap<unsigned, LiveInterval*>::iterator I = r2iMap_.begin(), @@ -96,7 +91,7 @@ void LiveIntervals::releaseMemory() { r2iMap_.clear(); // Release VNInfo memroy regions after all VNInfo objects are dtor'd. - VNInfoAllocator.Reset((unsigned)sizeof(VNInfo), alignof<VNInfo>(), VNInfoDTor); + VNInfoAllocator.DestroyAll(); while (!CloneMIs.empty()) { MachineInstr *MI = CloneMIs.back(); CloneMIs.pop_back(); diff --git a/lib/CodeGen/LiveStackAnalysis.cpp b/lib/CodeGen/LiveStackAnalysis.cpp index d2f3775..798b9b9 100644 --- a/lib/CodeGen/LiveStackAnalysis.cpp +++ b/lib/CodeGen/LiveStackAnalysis.cpp @@ -36,7 +36,7 @@ void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const { void LiveStacks::releaseMemory() { // Release VNInfo memroy regions after all VNInfo objects are dtor'd. - VNInfoAllocator.Reset(); + VNInfoAllocator.DestroyAll(); S2IMap.clear(); S2RCMap.clear(); } diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp index 70e91aa..2d49beb 100644 --- a/lib/CodeGen/PreAllocSplitting.cpp +++ b/lib/CodeGen/PreAllocSplitting.cpp @@ -665,7 +665,7 @@ PreAllocSplitting::PerformPHIConstructionFallBack(MachineBasicBlock::iterator Us /// ReconstructLiveInterval - Recompute a live interval from scratch. void PreAllocSplitting::ReconstructLiveInterval(LiveInterval* LI) { - BumpPtrAllocator& Alloc = LIs->getVNInfoAllocator(); + VNInfo::Allocator& Alloc = LIs->getVNInfoAllocator(); // Clear the old ranges and valnos; LI->clear(); diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp index 7433247..31b45c8 100644 --- a/lib/Support/Allocator.cpp +++ b/lib/Support/Allocator.cpp @@ -78,21 +78,6 @@ void BumpPtrAllocator::Reset() { End = ((char*)CurSlab) + CurSlab->Size; } -void BumpPtrAllocator::Reset(size_t Size, size_t Alignment, DTorFunction DTor) { - if (Alignment == 0) Alignment = 1; - MemSlab *Slab = CurSlab; - while (Slab) { - char *End = Slab == CurSlab ? CurPtr : (char*)Slab + Slab->Size; - for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += Size) { - Ptr = AlignPtr(Ptr, Alignment); - if (Ptr + Size <= End) - DTor(Ptr); - } - Slab = Slab->NextPtr; - } - Reset(); -} - /// Allocate - Allocate space at the specified alignment. /// void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { |