diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-17 04:04:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-17 04:04:14 +0000 |
commit | f8dfef74376dd85f37601855f7519d8256700dab (patch) | |
tree | 426e7bcdcbcd9beb1c684ced7f62ba3c3b1cbf2b /include/llvm/Module.h | |
parent | 17fcdd5e1b78b829068ca657c97357a39d6e768b (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 'include/llvm/Module.h')
-rw-r--r-- | include/llvm/Module.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/llvm/Module.h b/include/llvm/Module.h index e645f51c1c..1d82e2aad3 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -32,6 +32,7 @@ template<> struct ilist_traits<Function> static void destroySentinel(Function *F) { delete F; } static iplist<Function> &getList(Module *M); static inline ValueSymbolTable *getSymTab(Module *M); + static int getListOffset(); }; template<> struct ilist_traits<GlobalVariable> : public SymbolTableListTraits<GlobalVariable, Module> { @@ -40,6 +41,7 @@ template<> struct ilist_traits<GlobalVariable> static void destroySentinel(GlobalVariable *GV) { delete GV; } static iplist<GlobalVariable> &getList(Module *M); static inline ValueSymbolTable *getSymTab(Module *M); + static int getListOffset(); }; /// A Module instance is used to store all the information related to an @@ -313,6 +315,15 @@ public: /// that has "dropped all references", except operator delete. void dropAllReferences(); /// @} + + static unsigned getFunctionListOffset() { + Module *Obj = 0; + return reinterpret_cast<unsigned>(&Obj->FunctionList); + } + static unsigned getGlobalVariableListOffset() { + Module *Obj = 0; + return reinterpret_cast<unsigned>(&Obj->GlobalList); + } }; /// An iostream inserter for modules. @@ -331,6 +342,15 @@ ilist_traits<GlobalVariable>::getSymTab(Module *M) { return M ? &M->getValueSymbolTable() : 0; } +inline int +ilist_traits<Function>::getListOffset() { + return Module::getFunctionListOffset(); +} + +inline int +ilist_traits<GlobalVariable>::getListOffset() { + return Module::getGlobalVariableListOffset(); +} } // End llvm namespace |