aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-17 04:04:14 +0000
committerChris Lattner <sabre@nondot.org>2007-04-17 04:04:14 +0000
commitf8dfef74376dd85f37601855f7519d8256700dab (patch)
tree426e7bcdcbcd9beb1c684ced7f62ba3c3b1cbf2b /lib
parent17fcdd5e1b78b829068ca657c97357a39d6e768b (diff)
The (negative) offset from a SymbolTableListTraits-using ilist to its container
object is always constant. As such, evaluate it at compile time instead of storing it as an ivar in SymbolTableListTraits. This shrinks every SymbolTableListTraits ilist by a word, shrinking BasicBlock from 44->40 bytes, Function from 96->88 bytes, and Module from 60->52 bytes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36189 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/BasicBlock.cpp2
-rw-r--r--lib/VMCore/Function.cpp2
-rw-r--r--lib/VMCore/Module.cpp2
-rw-r--r--lib/VMCore/SymbolTableListTraitsImpl.h17
4 files changed, 9 insertions, 14 deletions
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index e10948e2ad..431bb5090a 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -72,8 +72,6 @@ template class SymbolTableListTraits<Instruction, BasicBlock>;
BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
BasicBlock *InsertBefore)
: Value(Type::LabelTy, Value::BasicBlockVal), Parent(0) {
- // Initialize the instlist.
- InstList.setItemParent(this);
// Make sure that we get added to a function
LeakDetector::addGarbageObject(this);
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 7949e39f84..e47798e12c 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -143,8 +143,6 @@ Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, 0, 0, Linkage, name) {
ParamAttrs = 0;
CallingConvention = 0;
- BasicBlocks.setItemParent(this);
- ArgumentList.setItemParent(this);
SymTab = new ValueSymbolTable();
assert((getReturnType()->isFirstClassType() ||getReturnType() == Type::VoidTy)
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp
index 465cb69445..ddd503dea1 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -64,8 +64,6 @@ template class SymbolTableListTraits<Function, Module>;
Module::Module(const std::string &MID)
: ModuleID(MID), DataLayout("") {
- FunctionList.setItemParent(this);
- GlobalList.setItemParent(this);
ValSymTab = new ValueSymbolTable();
TypeSymTab = new TypeSymbolTable();
}
diff --git a/lib/VMCore/SymbolTableListTraitsImpl.h b/lib/VMCore/SymbolTableListTraitsImpl.h
index ce2c0c0cc7..b2b6a3fa34 100644
--- a/lib/VMCore/SymbolTableListTraitsImpl.h
+++ b/lib/VMCore/SymbolTableListTraitsImpl.h
@@ -29,19 +29,19 @@ template<typename TPtr>
void SymbolTableListTraits<ValueSubClass,ItemParentClass>
::setSymTabObject(TPtr *Dest, TPtr Src) {
// Get the old symtab and value list before doing the assignment.
- ValueSymbolTable *OldST = TraitsClass::getSymTab(ItemParent);
+ ValueSymbolTable *OldST = TraitsClass::getSymTab(getListOwner());
// Do it.
*Dest = Src;
// Get the new SymTab object.
- ValueSymbolTable *NewST = TraitsClass::getSymTab(ItemParent);
+ ValueSymbolTable *NewST = TraitsClass::getSymTab(getListOwner());
// If there is nothing to do, quick exit.
if (OldST == NewST) return;
// Move all the elements from the old symtab to the new one.
- iplist<ValueSubClass> &ItemList = TraitsClass::getList(ItemParent);
+ iplist<ValueSubClass> &ItemList = TraitsClass::getList(getListOwner());
if (ItemList.empty()) return;
if (OldST) {
@@ -66,9 +66,10 @@ template<typename ValueSubClass, typename ItemParentClass>
void SymbolTableListTraits<ValueSubClass,ItemParentClass>
::addNodeToList(ValueSubClass *V) {
assert(V->getParent() == 0 && "Value already in a container!!");
- V->setParent(ItemParent);
+ ItemParentClass *Owner = getListOwner();
+ V->setParent(Owner);
if (V->hasName())
- if (ValueSymbolTable *ST = TraitsClass::getSymTab(ItemParent))
+ if (ValueSymbolTable *ST = TraitsClass::getSymTab(Owner))
ST->reinsertValue(V);
}
@@ -77,7 +78,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass>
::removeNodeFromList(ValueSubClass *V) {
V->setParent(0);
if (V->hasName())
- if (ValueSymbolTable *ST = TraitsClass::getSymTab(ItemParent))
+ if (ValueSymbolTable *ST = TraitsClass::getSymTab(getListOwner()))
ST->removeValueName(V->getValueName());
}
@@ -87,12 +88,12 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass>
ilist_iterator<ValueSubClass> first,
ilist_iterator<ValueSubClass> last) {
// We only have to do work here if transferring instructions between BBs
- ItemParentClass *NewIP = ItemParent, *OldIP = L2.ItemParent;
+ ItemParentClass *NewIP = getListOwner(), *OldIP = L2.getListOwner();
if (NewIP == OldIP) return; // No work to do at all...
// We only have to update symbol table entries if we are transferring the
// instructions to a different symtab object...
- ValueSymbolTable *NewST = TraitsClass::getSymTab(ItemParent);
+ ValueSymbolTable *NewST = TraitsClass::getSymTab(NewIP);
ValueSymbolTable *OldST = TraitsClass::getSymTab(OldIP);
if (NewST != OldST) {
for (; first != last; ++first) {