summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Archive/Archive.cpp4
-rw-r--r--lib/Archive/ArchiveReader.cpp2
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp2
-rw-r--r--lib/CodeGen/MachineBasicBlock.cpp36
-rw-r--r--lib/CodeGen/MachineFunction.cpp20
-rw-r--r--lib/CodeGen/MachineInstr.cpp9
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp98
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp29
-rw-r--r--lib/Support/Allocator.cpp6
-rw-r--r--lib/VMCore/BasicBlock.cpp5
-rw-r--r--lib/VMCore/SymbolTableListTraitsImpl.h2
11 files changed, 89 insertions, 124 deletions
diff --git a/lib/Archive/Archive.cpp b/lib/Archive/Archive.cpp
index a0e5eedc9c..776f4dd367 100644
--- a/lib/Archive/Archive.cpp
+++ b/lib/Archive/Archive.cpp
@@ -43,7 +43,7 @@ ArchiveMember::getMemberSize() const {
// This default constructor is only use by the ilist when it creates its
// sentry node. We give it specific static values to make it stand out a bit.
ArchiveMember::ArchiveMember()
- : next(0), prev(0), parent(0), path("--invalid--"), flags(0), data(0)
+ : parent(0), path("--invalid--"), flags(0), data(0)
{
info.user = sys::Process::GetCurrentUserId();
info.group = sys::Process::GetCurrentGroupId();
@@ -58,7 +58,7 @@ ArchiveMember::ArchiveMember()
// This is required because correctly setting the data may depend on other
// things in the Archive.
ArchiveMember::ArchiveMember(Archive* PAR)
- : next(0), prev(0), parent(PAR), path(), flags(0), data(0)
+ : parent(PAR), path(), flags(0), data(0)
{
}
diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp
index 1ded9e5c4c..8d607f0df7 100644
--- a/lib/Archive/ArchiveReader.cpp
+++ b/lib/Archive/ArchiveReader.cpp
@@ -218,8 +218,6 @@ Archive::parseMemberHeader(const char*& At, const char* End, std::string* error)
ArchiveMember* member = new ArchiveMember(this);
// Fill in fields of the ArchiveMember
- member->next = 0;
- member->prev = 0;
member->parent = this;
member->path.set(pathname);
member->info.fileSize = MemberSize;
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index baaed71d23..fde27b07a8 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -828,7 +828,7 @@ bool LiveIntervals::isReMaterializable(const LiveInterval &li,
// If the instruction accesses memory and the memory could be non-constant,
// assume the instruction is not rematerializable.
- for (alist<MachineMemOperand>::const_iterator I = MI->memoperands_begin(),
+ for (std::list<MachineMemOperand>::const_iterator I = MI->memoperands_begin(),
E = MI->memoperands_end(); I != E; ++I) {
const MachineMemOperand &MMO = *I;
if (MMO.isVolatile() || MMO.isStore())
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp
index 9a9f5b9271..5cfeeb63a7 100644
--- a/lib/CodeGen/MachineBasicBlock.cpp
+++ b/lib/CodeGen/MachineBasicBlock.cpp
@@ -24,7 +24,7 @@ using namespace llvm;
MachineBasicBlock::MachineBasicBlock(MachineFunction &mf, const BasicBlock *bb)
: BB(bb), Number(-1), xParent(&mf), Alignment(0), IsLandingPad(false) {
- Insts.getTraits().Parent = this;
+ Insts.Parent = this;
}
MachineBasicBlock::~MachineBasicBlock() {
@@ -43,7 +43,7 @@ std::ostream& llvm::operator<<(std::ostream &OS, const MachineBasicBlock &MBB) {
/// MBBs start out as #-1. When a MBB is added to a MachineFunction, it
/// gets the next available unique MBB number. If it is removed from a
/// MachineFunction, it goes back to being #-1.
-void alist_traits<MachineBasicBlock>::addNodeToList(MachineBasicBlock* N) {
+void ilist_traits<MachineBasicBlock>::addNodeToList(MachineBasicBlock* N) {
MachineFunction &MF = *N->getParent();
N->Number = MF.addToMBBNumbering(N);
@@ -55,7 +55,7 @@ void alist_traits<MachineBasicBlock>::addNodeToList(MachineBasicBlock* N) {
LeakDetector::removeGarbageObject(N);
}
-void alist_traits<MachineBasicBlock>::removeNodeFromList(MachineBasicBlock* N) {
+void ilist_traits<MachineBasicBlock>::removeNodeFromList(MachineBasicBlock* N) {
N->getParent()->removeFromMBBNumbering(N->Number);
N->Number = -1;
LeakDetector::addGarbageObject(N);
@@ -65,7 +65,7 @@ void alist_traits<MachineBasicBlock>::removeNodeFromList(MachineBasicBlock* N) {
/// addNodeToList (MI) - When we add an instruction to a basic block
/// list, we update its parent pointer and add its operands from reg use/def
/// lists if appropriate.
-void alist_traits<MachineInstr>::addNodeToList(MachineInstr* N) {
+void ilist_traits<MachineInstr>::addNodeToList(MachineInstr* N) {
assert(N->getParent() == 0 && "machine instruction already in a basic block");
N->setParent(Parent);
@@ -80,7 +80,7 @@ void alist_traits<MachineInstr>::addNodeToList(MachineInstr* N) {
/// removeNodeFromList (MI) - When we remove an instruction from a basic block
/// list, we update its parent pointer and remove its operands from reg use/def
/// lists if appropriate.
-void alist_traits<MachineInstr>::removeNodeFromList(MachineInstr* N) {
+void ilist_traits<MachineInstr>::removeNodeFromList(MachineInstr* N) {
assert(N->getParent() != 0 && "machine instruction not in a basic block");
// Remove from the use/def lists.
@@ -94,35 +94,23 @@ void alist_traits<MachineInstr>::removeNodeFromList(MachineInstr* N) {
/// transferNodesFromList (MI) - When moving a range of instructions from one
/// MBB list to another, we need to update the parent pointers and the use/def
/// lists.
-void alist_traits<MachineInstr>::transferNodesFromList(
- alist_traits<MachineInstr>& fromList,
+void ilist_traits<MachineInstr>::transferNodesFromList(
+ ilist_traits<MachineInstr>& fromList,
MachineBasicBlock::iterator first,
MachineBasicBlock::iterator last) {
+ assert(Parent->getParent() == fromList.Parent->getParent() &&
+ "MachineInstr parent mismatch!");
+
// Splice within the same MBB -> no change.
if (Parent == fromList.Parent) return;
// If splicing between two blocks within the same function, just update the
// parent pointers.
- if (Parent->getParent() == fromList.Parent->getParent()) {
- for (; first != last; ++first)
- first->setParent(Parent);
- return;
- }
-
- // Otherwise, we have to update the parent and the use/def lists. The common
- // case when this occurs is if we're splicing from a block in a MF to a block
- // that is not in an MF.
- bool HasOldMF = fromList.Parent->getParent() != 0;
- MachineFunction *NewMF = Parent->getParent();
-
- for (; first != last; ++first) {
- if (HasOldMF) first->RemoveRegOperandsFromUseLists();
+ for (; first != last; ++first)
first->setParent(Parent);
- if (NewMF) first->AddRegOperandsToUseLists(NewMF->getRegInfo());
- }
}
-void alist_traits<MachineInstr>::deleteNode(MachineInstr* MI) {
+void ilist_traits<MachineInstr>::deleteNode(MachineInstr* MI) {
assert(!MI->getParent() && "MI is still in a block!");
Parent->getParent()->DeleteMachineInstr(MI);
}
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 2cac96a4a8..b243297253 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -102,7 +102,7 @@ FunctionPass *llvm::createMachineCodeDeleter() {
// MachineFunction implementation
//===---------------------------------------------------------------------===//
-void alist_traits<MachineBasicBlock>::deleteNode(MachineBasicBlock *MBB) {
+void ilist_traits<MachineBasicBlock>::deleteNode(MachineBasicBlock *MBB) {
MBB->getParent()->DeleteMachineBasicBlock(MBB);
}
@@ -131,7 +131,6 @@ MachineFunction::~MachineFunction() {
BasicBlocks.clear();
InstructionRecycler.clear(Allocator);
BasicBlockRecycler.clear(Allocator);
- MemOperandRecycler.clear(Allocator);
RegInfo->~MachineRegisterInfo(); Allocator.Deallocate(RegInfo);
if (MFInfo) {
MFInfo->~MachineFunctionInfo(); Allocator.Deallocate(MFInfo);
@@ -234,23 +233,6 @@ MachineFunction::DeleteMachineBasicBlock(MachineBasicBlock *MBB) {
BasicBlockRecycler.Deallocate(Allocator, MBB);
}
-/// CreateMachineMemOperand - Allocate a new MachineMemOperand. Use this
-/// instead of `new MachineMemOperand'.
-///
-MachineMemOperand *
-MachineFunction::CreateMachineMemOperand(const MachineMemOperand &MMO) {
- return new (MemOperandRecycler.Allocate<MachineMemOperand>(Allocator))
- MachineMemOperand(MMO);
-}
-
-/// DeleteMachineMemOperand - Delete the given MachineMemOperand.
-///
-void
-MachineFunction::DeleteMachineMemOperand(MachineMemOperand *MO) {
- MO->~MachineMemOperand();
- MemOperandRecycler.Deallocate(Allocator, MO);
-}
-
void MachineFunction::dump() const {
print(*cerr.stream());
}
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index d577582637..c952293976 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -322,7 +322,7 @@ MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI)
NumImplicitOps = MI.NumImplicitOps;
// Add memory operands.
- for (alist<MachineMemOperand>::const_iterator i = MI.memoperands_begin(),
+ for (std::list<MachineMemOperand>::const_iterator i = MI.memoperands_begin(),
j = MI.memoperands_end(); i != j; ++i)
addMemOperand(MF, *i);
@@ -506,13 +506,12 @@ void MachineInstr::RemoveOperand(unsigned OpNo) {
/// referencing arbitrary storage.
void MachineInstr::addMemOperand(MachineFunction &MF,
const MachineMemOperand &MO) {
- MemOperands.push_back(MF.CreateMachineMemOperand(MO));
+ MemOperands.push_back(MO);
}
/// clearMemOperands - Erase all of this MachineInstr's MachineMemOperands.
void MachineInstr::clearMemOperands(MachineFunction &MF) {
- while (!MemOperands.empty())
- MF.DeleteMachineMemOperand(MemOperands.remove(MemOperands.begin()));
+ MemOperands.clear();
}
@@ -731,7 +730,7 @@ void MachineInstr::print(std::ostream &OS, const TargetMachine *TM) const {
if (!memoperands_empty()) {
OS << ", Mem:";
- for (alist<MachineMemOperand>::const_iterator i = memoperands_begin(),
+ for (std::list<MachineMemOperand>::const_iterator i = memoperands_begin(),
e = memoperands_end(); i != e; ++i) {
const MachineMemOperand &MRO = *i;
const Value *V = MRO.getValue();
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index c99d504f27..f8c11456d9 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -468,11 +468,6 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
// SelectionDAG Class
//===----------------------------------------------------------------------===//
-inline alist_traits<SDNode, LargestSDNode>::AllocatorType &
-SelectionDAG::getAllocator() {
- return AllNodes.getTraits().Allocator;
-}
-
/// RemoveDeadNodes - This method deletes all unreachable nodes in the
/// SelectionDAG.
void SelectionDAG::RemoveDeadNodes() {
@@ -527,7 +522,7 @@ void SelectionDAG::RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes,
N->NumOperands = 0;
// Finally, remove N itself.
- AllNodes.erase(N);
+ AllNodes.remove(N);
}
}
@@ -558,7 +553,7 @@ void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) {
N->OperandList = 0;
N->NumOperands = 0;
- AllNodes.erase(N);
+ AllNodes.remove(N);
}
/// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that
@@ -772,14 +767,13 @@ unsigned SelectionDAG::getMVTAlignment(MVT VT) const {
SelectionDAG::~SelectionDAG() {
while (!AllNodes.empty()) {
- SDNode *N = AllNodes.begin();
+ SDNode *N = AllNodes.remove(AllNodes.begin());
N->SetNextInBucket(0);
if (N->OperandsNeedDelete) {
delete [] N->OperandList;
}
N->OperandList = 0;
N->NumOperands = 0;
- AllNodes.pop_front();
}
}
@@ -813,7 +807,7 @@ SDValue SelectionDAG::getConstant(const APInt &Val, MVT VT, bool isT) {
if (!VT.isVector())
return SDValue(N, 0);
if (!N) {
- N = getAllocator().Allocate<ConstantSDNode>();
+ N = NodeAllocator.Allocate<ConstantSDNode>();
new (N) ConstantSDNode(isT, Val, EltVT);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -852,7 +846,7 @@ SDValue SelectionDAG::getConstantFP(const APFloat& V, MVT VT, bool isTarget) {
if (!VT.isVector())
return SDValue(N, 0);
if (!N) {
- N = getAllocator().Allocate<ConstantFPSDNode>();
+ N = NodeAllocator.Allocate<ConstantFPSDNode>();
new (N) ConstantFPSDNode(isTarget, V, EltVT);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -900,7 +894,7 @@ SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<GlobalAddressSDNode>();
+ SDNode *N = NodeAllocator.Allocate<GlobalAddressSDNode>();
new (N) GlobalAddressSDNode(isTargetGA, GV, VT, Offset);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -915,7 +909,7 @@ SDValue SelectionDAG::getFrameIndex(int FI, MVT VT, bool isTarget) {
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<FrameIndexSDNode>();
+ SDNode *N = NodeAllocator.Allocate<FrameIndexSDNode>();
new (N) FrameIndexSDNode(FI, VT, isTarget);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -930,7 +924,7 @@ SDValue SelectionDAG::getJumpTable(int JTI, MVT VT, bool isTarget){
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<JumpTableSDNode>();
+ SDNode *N = NodeAllocator.Allocate<JumpTableSDNode>();
new (N) JumpTableSDNode(JTI, VT, isTarget);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -949,7 +943,7 @@ SDValue SelectionDAG::getConstantPool(Constant *C, MVT VT,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<ConstantPoolSDNode>();
+ SDNode *N = NodeAllocator.Allocate<ConstantPoolSDNode>();
new (N) ConstantPoolSDNode(isTarget, C, VT, Offset, Alignment);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -969,7 +963,7 @@ SDValue SelectionDAG::getConstantPool(MachineConstantPoolValue *C, MVT VT,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<ConstantPoolSDNode>();
+ SDNode *N = NodeAllocator.Allocate<ConstantPoolSDNode>();
new (N) ConstantPoolSDNode(isTarget, C, VT, Offset, Alignment);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -984,7 +978,7 @@ SDValue SelectionDAG::getBasicBlock(MachineBasicBlock *MBB) {
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<BasicBlockSDNode>();
+ SDNode *N = NodeAllocator.Allocate<BasicBlockSDNode>();
new (N) BasicBlockSDNode(MBB);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -998,7 +992,7 @@ SDValue SelectionDAG::getArgFlags(ISD::ArgFlagsTy Flags) {
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<ARG_FLAGSSDNode>();
+ SDNode *N = NodeAllocator.Allocate<ARG_FLAGSSDNode>();
new (N) ARG_FLAGSSDNode(Flags);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -1013,7 +1007,7 @@ SDValue SelectionDAG::getValueType(MVT VT) {
ExtendedValueTypeNodes[VT] : ValueTypeNodes[VT.getSimpleVT()];
if (N) return SDValue(N, 0);
- N = getAllocator().Allocate<VTSDNode>();
+ N = NodeAllocator.Allocate<VTSDNode>();
new (N) VTSDNode(VT);
AllNodes.push_back(N);
return SDValue(N, 0);
@@ -1022,7 +1016,7 @@ SDValue SelectionDAG::getValueType(MVT VT) {
SDValue SelectionDAG::getExternalSymbol(const char *Sym, MVT VT) {
SDNode *&N = ExternalSymbols[Sym];
if (N) return SDValue(N, 0);
- N = getAllocator().Allocate<ExternalSymbolSDNode>();
+ N = NodeAllocator.Allocate<ExternalSymbolSDNode>();
new (N) ExternalSymbolSDNode(false, Sym, VT);
AllNodes.push_back(N);
return SDValue(N, 0);
@@ -1031,7 +1025,7 @@ SDValue SelectionDAG::getExternalSymbol(const char *Sym, MVT VT) {
SDValue SelectionDAG::getTargetExternalSymbol(const char *Sym, MVT VT) {
SDNode *&N = TargetExternalSymbols[Sym];
if (N) return SDValue(N, 0);
- N = getAllocator().Allocate<ExternalSymbolSDNode>();
+ N = NodeAllocator.Allocate<ExternalSymbolSDNode>();
new (N) ExternalSymbolSDNode(true, Sym, VT);
AllNodes.push_back(N);
return SDValue(N, 0);
@@ -1042,7 +1036,7 @@ SDValue SelectionDAG::getCondCode(ISD::CondCode Cond) {
CondCodeNodes.resize(Cond+1);
if (CondCodeNodes[Cond] == 0) {
- CondCodeSDNode *N = getAllocator().Allocate<CondCodeSDNode>();
+ CondCodeSDNode *N = NodeAllocator.Allocate<CondCodeSDNode>();
new (N) CondCodeSDNode(Cond);
CondCodeNodes[Cond] = N;
AllNodes.push_back(N);
@@ -1057,7 +1051,7 @@ SDValue SelectionDAG::getRegister(unsigned RegNo, MVT VT) {
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<RegisterSDNode>();
+ SDNode *N = NodeAllocator.Allocate<RegisterSDNode>();
new (N) RegisterSDNode(RegNo, VT);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -1065,9 +1059,9 @@ SDValue SelectionDAG::getRegister(unsigned RegNo, MVT VT) {
}
SDValue SelectionDAG::getDbgStopPoint(SDValue Root,
- unsigned Line, unsigned Col,
- const CompileUnitDesc *CU) {
- SDNode *N = getAllocator().Allocate<DbgStopPointSDNode>();
+ unsigned Line, unsigned Col,
+ const CompileUnitDesc *CU) {
+ SDNode *N = NodeAllocator.Allocate<DbgStopPointSDNode>();
new (N) DbgStopPointSDNode(Root, Line, Col, CU);
AllNodes.push_back(N);
return SDValue(N, 0);
@@ -1083,7 +1077,7 @@ SDValue SelectionDAG::getLabel(unsigned Opcode,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<LabelSDNode>();
+ SDNode *N = NodeAllocator.Allocate<LabelSDNode>();
new (N) LabelSDNode(Opcode, Root, LabelID);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -1102,7 +1096,7 @@ SDValue SelectionDAG::getSrcValue(const Value *V) {
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<SrcValueSDNode>();
+ SDNode *N = NodeAllocator.Allocate<SrcValueSDNode>();
new (N) SrcValueSDNode(V);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -1126,7 +1120,7 @@ SDValue SelectionDAG::getMemOperand(const MachineMemOperand &MO) {
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<MemOperandSDNode>();
+ SDNode *N = NodeAllocator.Allocate<MemOperandSDNode>();
new (N) MemOperandSDNode(MO);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -1979,7 +1973,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, MVT VT) {
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<SDNode>();
+ SDNode *N = NodeAllocator.Allocate<SDNode>();
new (N) SDNode(Opcode, SDNode::getSDVTList(VT));
CSEMap.InsertNode(N, IP);
@@ -2176,11 +2170,11 @@ SDValue SelectionDAG::getNode(unsigned Opcode, MVT VT, SDValue Operand) {
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- N = getAllocator().Allocate<UnarySDNode>();
+ N = NodeAllocator.Allocate<UnarySDNode>();
new (N) UnarySDNode(Opcode, VTs, Operand);
CSEMap.InsertNode(N, IP);
} else {
- N = getAllocator().Allocate<UnarySDNode>();
+ N = NodeAllocator.Allocate<UnarySDNode>();
new (N) UnarySDNode(Opcode, VTs, Operand);
}
@@ -2530,11 +2524,11 @@ SDValue SelectionDAG::getNode(unsigned Opcode, MVT VT,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- N = getAllocator().Allocate<BinarySDNode>();
+ N = NodeAllocator.Allocate<BinarySDNode>();
new (N) BinarySDNode(Opcode, VTs, N1, N2);
CSEMap.InsertNode(N, IP);
} else {
- N = getAllocator().Allocate<BinarySDNode>();
+ N = NodeAllocator.Allocate<BinarySDNode>();
new (N) BinarySDNode(Opcode, VTs, N1, N2);
}
@@ -2599,11 +2593,11 @@ SDValue SelectionDAG::getNode(unsigned Opcode, MVT VT,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- N = getAllocator().Allocate<TernarySDNode>();
+ N = NodeAllocator.Allocate<TernarySDNode>();
new (N) TernarySDNode(Opcode, VTs, N1, N2, N3);
CSEMap.InsertNode(N, IP);
} else {
- N = getAllocator().Allocate<TernarySDNode>();
+ N = NodeAllocator.Allocate<TernarySDNode>();
new (N) TernarySDNode(Opcode, VTs, N1, N2, N3);
}
AllNodes.push_back(N);
@@ -3121,7 +3115,7 @@ SDValue SelectionDAG::getAtomic(unsigned Opcode, SDValue Chain,
void* IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode* N = getAllocator().Allocate<AtomicSDNode>();
+ SDNode* N = NodeAllocator.Allocate<AtomicSDNode>();
new (N) AtomicSDNode(Opcode, VTs, Chain, Ptr, Cmp, Swp, PtrVal, Alignment);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -3152,7 +3146,7 @@ SDValue SelectionDAG::getAtomic(unsigned Opcode, SDValue Chain,
void* IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode* N = getAllocator().Allocate<AtomicSDNode>();
+ SDNode* N = NodeAllocator.Allocate<AtomicSDNode>();
new (N) AtomicSDNode(Opcode, VTs, Chain, Ptr, Val, PtrVal, Alignment);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
@@ -3216,7 +3210,7 @@ SelectionDAG::getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<LoadSDNode>();
+ SDNode *N = NodeAllocator.Allocate<LoadSDNode>();
new (N) LoadSDNode(Ops, VTs, AM, ExtType, EVT, SV, SVOffset,
Alignment, isVolatile);
CSEMap.InsertNode(N, IP);
@@ -3276,7 +3270,7 @@ SDValue SelectionDAG::getStore(SDValue Chain, SDValue Val,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<StoreSDNode>();
+ SDNode *N = NodeAllocator.Allocate<StoreSDNode>();
new (N) StoreSDNode(Ops, VTs, ISD::UNINDEXED, false,
VT, SV, SVOffset, Alignment, isVolatile);
CSEMap.InsertNode(N, IP);
@@ -3313,7 +3307,7 @@ SDValue SelectionDAG::getTruncStore(SDValue Chain, SDValue Val,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<StoreSDNode>();
+ SDNode *N = NodeAllocator.Allocate<StoreSDNode>();
new (N) StoreSDNode(Ops, VTs, ISD::UNINDEXED, true,
SVT, SV, SVOffset, Alignment, isVolatile);
CSEMap.InsertNode(N, IP);
@@ -3339,7 +3333,7 @@ SelectionDAG::getIndexedStore(SDValue OrigStore, SDValue Base,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- SDNode *N = getAllocator().Allocate<StoreSDNode>();
+ SDNode *N = NodeAllocator.Allocate<StoreSDNode>();
new (N) StoreSDNode(Ops, VTs, AM,
ST->isTruncatingStore(), ST->getMemoryVT(),
ST->getSrcValue(), ST->getSrcValueOffset(),
@@ -3411,11 +3405,11 @@ SDValue SelectionDAG::getNode(unsigned Opcode, MVT VT,
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- N = getAllocator().Allocate<SDNode>();
+ N = NodeAllocator.Allocate<SDNode>();
new (N) SDNode(Opcode, VTs, Ops, NumOps);
CSEMap.InsertNode(N, IP);
} else {
- N = getAllocator().Allocate<SDNode>();
+ N = NodeAllocator.Allocate<SDNode>();
new (N) SDNode(Opcode, VTs, Ops, NumOps);
}
AllNodes.push_back(N);
@@ -3477,31 +3471,31 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDVTList VTList,
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
if (NumOps == 1) {
- N = getAllocator().Allocate<UnarySDNode>();
+ N = NodeAllocator.Allocate<UnarySDNode>();
new (N) UnarySDNode(Opcode, VTList, Ops[0]);
} else if (NumOps == 2) {
- N = getAllocator().Allocate<BinarySDNode>();
+ N = NodeAllocator.Allocate<BinarySDNode>();
new (N) BinarySDNode(Opcode, VTList, Ops[0], Ops[1]);
} else if (NumOps == 3) {
- N = getAllocator().Allocate<TernarySDNode>();
+ N = NodeAllocator.Allocate<TernarySDNode>();
new (N) TernarySDNode(Opcode, VTList, Ops[0], Ops[1], Ops[2]);
} else {
- N = getAllocator().Allocate<SDNode>();
+ N = NodeAllocator.Allocate<SDNode>();
new (N) SDNode(Opcode, VTList, Ops, NumOps);
}
CSEMap.InsertNode(N, IP);
} else {
if (NumOps == 1) {
- N = getAllocator().Allocate<UnarySDNode>();
+ N = NodeAllocator.Allocate<UnarySDNode>();
new (N) UnarySDNode(Opcode, VTList, Ops[0]);
} else if (NumOps == 2) {
- N = getAllocator().Allocate<BinarySDNode>();
+ N = NodeAllocator.Allocate<BinarySDNode>();
new (N) BinarySDNode(Opcode, VTList, Ops[0], Ops[1]);
} else if (NumOps == 3) {
- N = getAllocator().Allocate<TernarySDNode>();
+ N = NodeAllocator.Allocate<TernarySDNode>();
new (N) TernarySDNode(Opcode, VTList, Ops[0], Ops[1], Ops[2]);
} else {
- N = getAllocator().Allocate<SDNode>();
+ N = NodeAllocator.Allocate<SDNode>();
new (N) SDNode(Opcode, VTList, Ops, NumOps);
}
}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 7d34ca2744..c0652da35d 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -5425,24 +5425,23 @@ void SelectionDAGISel::CodeGenAndEmitDAG(SelectionDAG &DAG) {
void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
FunctionLoweringInfo &FuncInfo) {
- // Define AllNodes here so that memory allocation is reused for
+ // Define NodeAllocator here so that memory allocation is reused for
// each basic block.
- alist<SDNode, LargestSDNode> AllNodes;
+ NodeAllocatorType NodeAllocator;
- for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) {
- SelectBasicBlock(I, MF, FuncInfo, AllNodes);
- AllNodes.clear();
- }
+ for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
+ SelectBasicBlock(I, MF, FuncInfo, NodeAllocator);
}
-void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
- FunctionLoweringInfo &FuncInfo,
- alist<SDNode, LargestSDNode> &AllNodes) {
+void
+SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
+ FunctionLoweringInfo &FuncInfo,
+ NodeAllocatorType &NodeAllocator) {
std::vector<std::pair<MachineInstr*, unsigned> > PHINodesToUpdate;
{
SelectionDAG DAG(TLI, MF, FuncInfo,
getAnalysisToUpdate<MachineModuleInfo>(),
- AllNodes);
+ NodeAllocator);
CurDAG = &DAG;
// First step, lower LLVM code to some DAG. This DAG may use operations and
@@ -5478,7 +5477,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
if (!BitTestCases[i].Emitted) {
SelectionDAG HSDAG(TLI, MF, FuncInfo,
getAnalysisToUpdate<MachineModuleInfo>(),
- AllNodes);
+ NodeAllocator);
CurDAG = &HSDAG;
SelectionDAGLowering HSDL(HSDAG, TLI, *AA, FuncInfo, GCI);
// Set the current basic block to the mbb we wish to insert the code into
@@ -5493,7 +5492,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
for (unsigned j = 0, ej = BitTestCases[i].Cases.size(); j != ej; ++j) {
SelectionDAG BSDAG(TLI, MF, FuncInfo,
getAnalysisToUpdate<MachineModuleInfo>(),
- AllNodes);
+ NodeAllocator);
CurDAG = &BSDAG;
SelectionDAGLowering BSDL(BSDAG, TLI, *AA, FuncInfo, GCI);
// Set the current basic block to the mbb we wish to insert the code into
@@ -5552,7 +5551,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
if (!JTCases[i].first.Emitted) {
SelectionDAG HSDAG(TLI, MF, FuncInfo,
getAnalysisToUpdate<MachineModuleInfo>(),
- AllNodes);
+ NodeAllocator);
CurDAG = &HSDAG;
SelectionDAGLowering HSDL(HSDAG, TLI, *AA, FuncInfo, GCI);
// Set the current basic block to the mbb we wish to insert the code into
@@ -5566,7 +5565,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
SelectionDAG JSDAG(TLI, MF, FuncInfo,
getAnalysisToUpdate<MachineModuleInfo>(),
- AllNodes);
+ NodeAllocator);
CurDAG = &JSDAG;
SelectionDAGLowering JSDL(JSDAG, TLI, *AA, FuncInfo, GCI);
// Set the current basic block to the mbb we wish to insert the code into
@@ -5616,7 +5615,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
for (unsigned i = 0, e = SwitchCases.size(); i != e; ++i) {
SelectionDAG SDAG(TLI, MF, FuncInfo,
getAnalysisToUpdate<MachineModuleInfo>(),
- AllNodes);
+ NodeAllocator);
CurDAG = &SDAG;
SelectionDAGLowering SDL(SDAG, TLI, *AA, FuncInfo, GCI);
diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp
index 584ca125b7..db0d8f31e5 100644
--- a/lib/Support/Allocator.cpp
+++ b/lib/Support/Allocator.cpp
@@ -132,8 +132,10 @@ void BumpPtrAllocator::PrintStats() const {
cerr << "Bytes allocated: " << BytesUsed << "\n";
}
-void llvm::PrintRecyclerStats(size_t LargestTypeSize,
+void llvm::PrintRecyclerStats(size_t Size,
+ size_t Align,
size_t FreeListSize) {
- cerr << "Recycler element size: " << LargestTypeSize << '\n';
+ cerr << "Recycler element size: " << Size << '\n';
+ cerr << "Recycler element alignment: " << Align << '\n';
cerr << "Number of elements free for recycling: " << FreeListSize << '\n';
}
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index 64711fea0c..514aa1de23 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -15,6 +15,7 @@
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/Type.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/Compiler.h"
@@ -260,7 +261,9 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const std::string &BBName) {
assert(I != InstList.end() &&
"Trying to get me to create degenerate basic block!");
- BasicBlock *New = BasicBlock::Create(BBName, getParent(), getNext());
+ BasicBlock *InsertBefore = next(Function::iterator(this))
+ .getNodePtrUnchecked();
+ BasicBlock *New = BasicBlock::Create(BBName, getParent(), InsertBefore);
// Move all of the specified instructions from the original basic block into
// the new basic block.
diff --git a/lib/VMCore/SymbolTableListTraitsImpl.h b/lib/VMCore/SymbolTableListTraitsImpl.h
index 2a3b3d835d..72687bb5e0 100644
--- a/lib/VMCore/SymbolTableListTraitsImpl.h
+++ b/lib/VMCore/SymbolTableListTraitsImpl.h
@@ -84,7 +84,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass>
template<typename ValueSubClass, typename ItemParentClass>
void SymbolTableListTraits<ValueSubClass,ItemParentClass>
-::transferNodesFromList(iplist<ValueSubClass, ilist_traits<ValueSubClass> > &L2,
+::transferNodesFromList(ilist_traits<ValueSubClass> &L2,
ilist_iterator<ValueSubClass> first,
ilist_iterator<ValueSubClass> last) {
// We only have to do work here if transferring instructions between BBs