diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-17 03:26:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-17 03:26:42 +0000 |
commit | 17fcdd5e1b78b829068ca657c97357a39d6e768b (patch) | |
tree | db5c01cfda299d428837e2689e9aca31bf1bf556 /lib/VMCore/BasicBlock.cpp | |
parent | 205c27d4a904c12d1bfb0b2961daab70f286cc20 (diff) |
Refactor SymbolTableListTraits to only have a single pointer in it, instead
of two. This shrinkifies Function by 8 bytes (104->96) and Module by 8
bytes (68->60). On a testcase of mine, this reduces the memory used to
read a module header from 565680b to 561024, a little over 4K.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36188 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/BasicBlock.cpp')
-rw-r--r-- | lib/VMCore/BasicBlock.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 2e3b426e2b..e10948e2ad 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -22,6 +22,15 @@ #include <algorithm> using namespace llvm; +inline ValueSymbolTable * +ilist_traits<Instruction>::getSymTab(BasicBlock *BB) { + if (BB) + if (Function *F = BB->getParent()) + return &F->getValueSymbolTable(); + return 0; +} + + namespace { /// DummyInst - An instance of this class is used to mark the end of the /// instruction list. This is not a real instruction. @@ -57,24 +66,24 @@ iplist<Instruction> &ilist_traits<Instruction>::getList(BasicBlock *BB) { // Explicit instantiation of SymbolTableListTraits since some of the methods // are not in the public header file... -template class SymbolTableListTraits<Instruction, BasicBlock, Function>; +template class SymbolTableListTraits<Instruction, BasicBlock>; -BasicBlock::BasicBlock(const std::string &Name, Function *Parent, +BasicBlock::BasicBlock(const std::string &Name, Function *NewParent, BasicBlock *InsertBefore) - : Value(Type::LabelTy, Value::BasicBlockVal) { - // Initialize the instlist... + : 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); if (InsertBefore) { - assert(Parent && + assert(NewParent && "Cannot insert block before another block with no function!"); - Parent->getBasicBlockList().insert(InsertBefore, this); - } else if (Parent) { - Parent->getBasicBlockList().push_back(this); + NewParent->getBasicBlockList().insert(InsertBefore, this); + } else if (NewParent) { + NewParent->getBasicBlockList().push_back(this); } setName(Name); @@ -91,7 +100,8 @@ void BasicBlock::setParent(Function *parent) { if (getParent()) LeakDetector::addGarbageObject(this); - InstList.setParent(parent); + // Set Parent=parent, updating instruction symtab entries as appropriate. + InstList.setSymTabObject(&Parent, parent); if (getParent()) LeakDetector::removeGarbageObject(this); |