Changes in directory llvm/lib/VMCore:

BasicBlock.cpp updated: 1.76 -> 1.77
Function.cpp updated: 1.122 -> 1.123
Module.cpp updated: 1.79 -> 1.80
SymbolTableListTraitsImpl.h updated: 1.11 -> 1.12
---
Log message:

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.


---
Diffs of the changes:  (+9 -14)

 BasicBlock.cpp              |    2 --
 Function.cpp                |    2 --
 Module.cpp                  |    2 --
 SymbolTableListTraitsImpl.h |   17 +++++++++--------
 4 files changed, 9 insertions(+), 14 deletions(-)


Index: llvm/lib/VMCore/BasicBlock.cpp
diff -u llvm/lib/VMCore/BasicBlock.cpp:1.76 llvm/lib/VMCore/BasicBlock.cpp:1.77
--- llvm/lib/VMCore/BasicBlock.cpp:1.76 Mon Apr 16 22:26:42 2007
+++ llvm/lib/VMCore/BasicBlock.cpp      Mon Apr 16 23:04:14 2007
@@ -72,8 +72,6 @@
 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);


Index: llvm/lib/VMCore/Function.cpp
diff -u llvm/lib/VMCore/Function.cpp:1.122 llvm/lib/VMCore/Function.cpp:1.123
--- llvm/lib/VMCore/Function.cpp:1.122  Mon Apr 16 22:26:42 2007
+++ llvm/lib/VMCore/Function.cpp        Mon Apr 16 23:04:14 2007
@@ -143,8 +143,6 @@
   : 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)


Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.79 llvm/lib/VMCore/Module.cpp:1.80
--- llvm/lib/VMCore/Module.cpp:1.79     Mon Apr 16 22:26:42 2007
+++ llvm/lib/VMCore/Module.cpp  Mon Apr 16 23:04:14 2007
@@ -64,8 +64,6 @@
 
 Module::Module(const std::string &MID)
   : ModuleID(MID), DataLayout("") {
-  FunctionList.setItemParent(this);
-  GlobalList.setItemParent(this);
   ValSymTab = new ValueSymbolTable();
   TypeSymTab = new TypeSymbolTable();
 }


Index: llvm/lib/VMCore/SymbolTableListTraitsImpl.h
diff -u llvm/lib/VMCore/SymbolTableListTraitsImpl.h:1.11 
llvm/lib/VMCore/SymbolTableListTraitsImpl.h:1.12
--- llvm/lib/VMCore/SymbolTableListTraitsImpl.h:1.11    Mon Apr 16 22:26:42 2007
+++ llvm/lib/VMCore/SymbolTableListTraitsImpl.h Mon Apr 16 23:04:14 2007
@@ -29,19 +29,19 @@
 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 @@
 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 @@
 ::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 @@
                         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) {



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to