[llvm-branch-commits] [llvm-branch] r100445 - in /llvm/branches/Apple/Morbo: ./ include/llvm/CodeGen/LiveInterval.h include/llvm/CodeGen/LiveIntervalAnalysis.h include/llvm/CodeGen/LiveStackAnalysis.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/LiveStackAnalysis.cpp lib/CodeGen/PreAllocSplitting.cpp lib/Transforms/IPO/FunctionAttrs.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon Apr 5 11:23:49 PDT 2010
Author: stoklund
Date: Mon Apr 5 13:23:49 2010
New Revision: 100445
URL: http://llvm.org/viewvc/llvm-project?rev=100445&view=rev
Log:
Merge from trunk: 99881 99882 99883 99895 99919 100184.
This implements SpecificBumpPtrAllocator.
Modified:
llvm/branches/Apple/Morbo/ (props changed)
llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveInterval.h
llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveIntervalAnalysis.h
llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveStackAnalysis.h
llvm/branches/Apple/Morbo/include/llvm/Support/Allocator.h
llvm/branches/Apple/Morbo/lib/CodeGen/LiveInterval.cpp
llvm/branches/Apple/Morbo/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/branches/Apple/Morbo/lib/CodeGen/LiveStackAnalysis.cpp
llvm/branches/Apple/Morbo/lib/CodeGen/PreAllocSplitting.cpp
llvm/branches/Apple/Morbo/lib/Transforms/IPO/FunctionAttrs.cpp (props changed)
Propchange: llvm/branches/Apple/Morbo/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Apr 5 13:23:49 2010
@@ -1,2 +1,2 @@
/llvm/branches/Apple/Hermes:96832,96835,96858,96870,96876,96879
-/llvm/trunk:98602,98604,98612,98615-98616,98675,98686,98743-98744,98773,98778,98780,98810,98835,98839,98845,98855,98862,98881,98920,98977,99032-99033,99043,99196,99223,99263,99282-99284,99306,99319-99321,99324,99336,99378,99418,99423,99429,99455,99463,99465,99469,99484,99490,99492-99494,99507,99524,99537,99539-99540,99544,99570,99575,99598,99620,99629-99630,99636,99671,99692,99695,99697,99699,99722,99816,99836,99845-99846,99848,99850,99855,99879,99899,99910,99916,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100072,100074,100081-100090,100092,100094-100095,100116,100134,100209,100214-100218,100220-100221,100223-100225,100257,100261
+/llvm/trunk:98602,98604,98612,98615-98616,98675,98686,98743-98744,98773,98778,98780,98810,98835,98839,98845,98855,98862,98881,98920,98977,99032-99033,99043,99196,99223,99263,99282-99284,99306,99319-99321,99324,99336,99378,99418,99423,99429,99455,99463,99465,99469,99484,99490,99492-99494,99507,99524,99537,99539-99540,99544,99570,99575,99598,99620,99629-99630,99636,99671,99692,99695,99697,99699,99722,99816,99836,99845-99846,99848,99850,99855,99879,99881-99883,99895,99899,99910,99916,99919,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100072,100074,100081-100090,100092,100094-100095,100116,100134,100184,100209,100214-100218,100220-100221,100223-100225,100257,100261
Modified: llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveInterval.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveInterval.h?rev=100445&r1=100444&r2=100445&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveInterval.h Mon Apr 5 13:23:49 2010
@@ -67,7 +67,7 @@
} cr;
public:
-
+ typedef SpecificBumpPtrAllocator<VNInfo> Allocator;
typedef SmallVector<SlotIndex, 4> KillSet;
/// The ID number of this value.
@@ -330,12 +330,7 @@
}
void clear() {
- while (!valnos.empty()) {
- VNInfo *VNI = valnos.back();
- valnos.pop_back();
- VNI->~VNInfo();
- }
-
+ valnos.clear();
ranges.clear();
}
@@ -370,10 +365,8 @@
/// getNextValue - Create a new value number and return it. MIIdx specifies
/// the instruction that defines the value number.
VNInfo *getNextValue(SlotIndex def, MachineInstr *CopyMI,
- bool isDefAccurate, BumpPtrAllocator &VNInfoAllocator){
- VNInfo *VNI =
- static_cast<VNInfo*>(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo),
- alignof<VNInfo>()));
+ bool isDefAccurate, VNInfo::Allocator &VNInfoAllocator) {
+ VNInfo *VNI = VNInfoAllocator.Allocate();
new (VNI) VNInfo((unsigned)valnos.size(), def, CopyMI);
VNI->setIsDefAccurate(isDefAccurate);
valnos.push_back(VNI);
@@ -383,11 +376,8 @@
/// Create a copy of the given value. The new value will be identical except
/// for the Value number.
VNInfo *createValueCopy(const VNInfo *orig,
- BumpPtrAllocator &VNInfoAllocator) {
- VNInfo *VNI =
- static_cast<VNInfo*>(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo),
- alignof<VNInfo>()));
-
+ VNInfo::Allocator &VNInfoAllocator) {
+ VNInfo *VNI = VNInfoAllocator.Allocate();
new (VNI) VNInfo((unsigned)valnos.size(), *orig);
valnos.push_back(VNI);
return VNI;
@@ -427,14 +417,14 @@
/// VNInfoAllocator since it will create a new val#.
void MergeInClobberRanges(LiveIntervals &li_,
const LiveInterval &Clobbers,
- BumpPtrAllocator &VNInfoAllocator);
+ VNInfo::Allocator &VNInfoAllocator);
/// MergeInClobberRange - Same as MergeInClobberRanges except it merge in a
/// single LiveRange only.
void MergeInClobberRange(LiveIntervals &li_,
SlotIndex Start,
SlotIndex End,
- BumpPtrAllocator &VNInfoAllocator);
+ VNInfo::Allocator &VNInfoAllocator);
/// MergeValueInAsValue - Merge all of the live ranges of a specific val#
/// in RHS into this live interval as the specified value number.
@@ -454,7 +444,7 @@
/// Copy - Copy the specified live interval. This copies all the fields
/// except for the register of the interval.
void Copy(const LiveInterval &RHS, MachineRegisterInfo *MRI,
- BumpPtrAllocator &VNInfoAllocator);
+ VNInfo::Allocator &VNInfoAllocator);
bool empty() const { return ranges.empty(); }
Modified: llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveIntervalAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=100445&r1=100444&r2=100445&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveIntervalAnalysis.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveIntervalAnalysis.h Mon Apr 5 13:23:49 2010
@@ -55,7 +55,7 @@
/// Special pool allocator for VNInfo's (LiveInterval val#).
///
- BumpPtrAllocator VNInfoAllocator;
+ VNInfo::Allocator VNInfoAllocator;
typedef DenseMap<unsigned, LiveInterval*> Reg2IntervalMap;
Reg2IntervalMap r2iMap_;
@@ -221,7 +221,7 @@
indexes_->renumberIndexes();
}
- BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; }
+ VNInfo::Allocator& getVNInfoAllocator() { return VNInfoAllocator; }
/// getVNInfoSourceReg - Helper function that parses the specified VNInfo
/// copy field and returns the source register that defines it.
Modified: llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveStackAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveStackAnalysis.h?rev=100445&r1=100444&r2=100445&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveStackAnalysis.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/CodeGen/LiveStackAnalysis.h Mon Apr 5 13:23:49 2010
@@ -27,7 +27,7 @@
class LiveStacks : public MachineFunctionPass {
/// Special pool allocator for VNInfo's (LiveInterval val#).
///
- BumpPtrAllocator VNInfoAllocator;
+ VNInfo::Allocator VNInfoAllocator;
/// S2IMap - Stack slot indices to live interval mapping.
///
@@ -91,7 +91,7 @@
return I->second;
}
- BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; }
+ VNInfo::Allocator& getVNInfoAllocator() { return VNInfoAllocator; }
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
virtual void releaseMemory();
Modified: llvm/branches/Apple/Morbo/include/llvm/Support/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/Support/Allocator.h?rev=100445&r1=100444&r2=100445&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/Support/Allocator.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/Support/Allocator.h Mon Apr 5 13:23:49 2010
@@ -133,6 +133,7 @@
static MallocSlabAllocator DefaultSlabAllocator;
+ template<typename T> friend class SpecificBumpPtrAllocator;
public:
BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096,
SlabAllocator &allocator = DefaultSlabAllocator);
@@ -176,6 +177,45 @@
void PrintStats() const;
};
+/// SpecificBumpPtrAllocator - Same as BumpPtrAllocator but allows only
+/// elements of one type to be allocated. This allows calling the destructor
+/// in DestroyAll() and when the allocator is destroyed.
+template <typename T>
+class SpecificBumpPtrAllocator {
+ BumpPtrAllocator Allocator;
+public:
+ SpecificBumpPtrAllocator(size_t size = 4096, size_t threshold = 4096,
+ SlabAllocator &allocator = BumpPtrAllocator::DefaultSlabAllocator)
+ : Allocator(size, threshold, allocator) {}
+
+ ~SpecificBumpPtrAllocator() {
+ DestroyAll();
+ }
+
+ /// Call the destructor of each allocated object and deallocate all but the
+ /// current slab and reset the current pointer to the beginning of it, freeing
+ /// all memory allocated so far.
+ void DestroyAll() {
+ MemSlab *Slab = Allocator.CurSlab;
+ while (Slab) {
+ char *End = Slab == Allocator.CurSlab ? Allocator.CurPtr :
+ (char *)Slab + Slab->Size;
+ for (char *Ptr = (char*)(Slab+1); Ptr < End; Ptr += sizeof(T)) {
+ Ptr = Allocator.AlignPtr(Ptr, alignof<T>());
+ if (Ptr + sizeof(T) <= End)
+ reinterpret_cast<T*>(Ptr)->~T();
+ }
+ Slab = Slab->NextPtr;
+ }
+ Allocator.Reset();
+ }
+
+ /// Allocate space for a specific count of elements.
+ T *Allocate(size_t num = 1) {
+ return Allocator.Allocate<T>(num);
+ }
+};
+
} // end namespace llvm
inline void *operator new(size_t Size, llvm::BumpPtrAllocator &Allocator) {
Modified: llvm/branches/Apple/Morbo/lib/CodeGen/LiveInterval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/LiveInterval.cpp?rev=100445&r1=100444&r2=100445&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/LiveInterval.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/LiveInterval.cpp Mon Apr 5 13:23:49 2010
@@ -303,9 +303,7 @@
// otherwise mark it as ~1U so it can be nuked later.
if (ValNo->id == getNumValNums()-1) {
do {
- VNInfo *VNI = valnos.back();
valnos.pop_back();
- VNI->~VNInfo();
} while (!valnos.empty() && valnos.back()->isUnused());
} else {
ValNo->setIsUnused(true);
@@ -351,9 +349,7 @@
// otherwise mark it as ~1U so it can be nuked later.
if (ValNo->id == getNumValNums()-1) {
do {
- VNInfo *VNI = valnos.back();
valnos.pop_back();
- VNI->~VNInfo();
} while (!valnos.empty() && valnos.back()->isUnused());
} else {
ValNo->setIsUnused(true);
@@ -579,9 +575,7 @@
// mark it as ~1U so it can be nuked later.
if (V1->id == getNumValNums()-1) {
do {
- VNInfo *VNI = valnos.back();
valnos.pop_back();
- VNI->~VNInfo();
} while (!valnos.empty() && valnos.back()->isUnused());
} else {
V1->setIsUnused(true);
@@ -597,7 +591,7 @@
/// 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,14 +652,13 @@
if (UnusedValNo) {
// Delete the last unused val#.
valnos.pop_back();
- UnusedValNo->~VNInfo();
}
}
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 =
@@ -749,9 +742,7 @@
// ~1U so it can be nuked later.
if (V1->id == getNumValNums()-1) {
do {
- VNInfo *VNI = valnos.back();
valnos.pop_back();
- VNI->~VNInfo();
} while (valnos.back()->isUnused());
} else {
V1->setIsUnused(true);
@@ -762,7 +753,7 @@
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);
Modified: llvm/branches/Apple/Morbo/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=100445&r1=100444&r2=100445&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Apr 5 13:23:49 2010
@@ -91,7 +91,7 @@
r2iMap_.clear();
// Release VNInfo memroy regions after all VNInfo objects are dtor'd.
- VNInfoAllocator.Reset();
+ VNInfoAllocator.DestroyAll();
while (!CloneMIs.empty()) {
MachineInstr *MI = CloneMIs.back();
CloneMIs.pop_back();
Modified: llvm/branches/Apple/Morbo/lib/CodeGen/LiveStackAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/LiveStackAnalysis.cpp?rev=100445&r1=100444&r2=100445&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/LiveStackAnalysis.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/LiveStackAnalysis.cpp Mon Apr 5 13:23:49 2010
@@ -36,7 +36,7 @@
void LiveStacks::releaseMemory() {
// Release VNInfo memroy regions after all VNInfo objects are dtor'd.
- VNInfoAllocator.Reset();
+ VNInfoAllocator.DestroyAll();
S2IMap.clear();
S2RCMap.clear();
}
Modified: llvm/branches/Apple/Morbo/lib/CodeGen/PreAllocSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/PreAllocSplitting.cpp?rev=100445&r1=100444&r2=100445&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/PreAllocSplitting.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/PreAllocSplitting.cpp Mon Apr 5 13:23:49 2010
@@ -665,7 +665,7 @@
/// 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();
Propchange: llvm/branches/Apple/Morbo/lib/Transforms/IPO/FunctionAttrs.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Apr 5 13:23:49 2010
@@ -1 +1 @@
-/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp:99196,99492,99507,99524,99539-99540,99636,99699,99816,99836,99845-99846,99848,99850,99855,99879,99899,99910,99916,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100072,100074,100081-100090,100092,100094-100095,100116,100132-100134,100137,100170,100208-100209,100214-100218,100220-100221,100223-100225,100257,100261
+/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp:99196,99492,99507,99524,99539-99540,99636,99699,99816,99836,99845-99846,99848,99850,99855,99879,99881-99883,99895,99899,99910,99916,99919,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100072,100074,100081-100090,100092,100094-100095,100116,100132-100134,100137,100170,100184,100208-100209,100214-100218,100220-100221,100223-100225,100257,100261
More information about the llvm-branch-commits
mailing list