aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Function.h
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 /include/llvm/Function.h
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 'include/llvm/Function.h')
-rw-r--r--include/llvm/Function.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index d42c8d8aa2..3fdbd02500 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -37,6 +37,7 @@ template<> struct ilist_traits<BasicBlock>
static void destroySentinel(BasicBlock *BB) { delete BB; }
static iplist<BasicBlock> &getList(Function *F);
static ValueSymbolTable *getSymTab(Function *ItemParent);
+ static int getListOffset();
};
template<> struct ilist_traits<Argument>
@@ -47,6 +48,7 @@ template<> struct ilist_traits<Argument>
static void destroySentinel(Argument *A) { delete A; }
static iplist<Argument> &getList(Function *F);
static ValueSymbolTable *getSymTab(Function *ItemParent);
+ static int getListOffset();
};
class Function : public GlobalValue, public Annotable {
@@ -238,6 +240,15 @@ public:
/// including any contained basic blocks.
///
void dropAllReferences();
+
+ static unsigned getBasicBlockListOffset() {
+ Function *Obj = 0;
+ return reinterpret_cast<unsigned>(&Obj->BasicBlocks);
+ }
+ static unsigned getArgumentListOffset() {
+ Function *Obj = 0;
+ return reinterpret_cast<unsigned>(&Obj->ArgumentList);
+ }
};
inline ValueSymbolTable *
@@ -250,6 +261,17 @@ ilist_traits<Argument>::getSymTab(Function *F) {
return F ? &F->getValueSymbolTable() : 0;
}
+inline int
+ilist_traits<BasicBlock>::getListOffset() {
+ return Function::getBasicBlockListOffset();
+}
+
+inline int
+ilist_traits<Argument>::getListOffset() {
+ return Function::getArgumentListOffset();
+}
+
+
} // End llvm namespace
#endif