[llvm-commits] [llvm] r65776 - in /llvm/trunk: include/llvm/Function.h lib/VMCore/Function.cpp
Gabor Greif
ggreif at gmail.com
Sun Mar 1 08:38:10 PST 2009
Author: ggreif
Date: Sun Mar 1 10:38:10 2009
New Revision: 65776
URL: http://llvm.org/viewvc/llvm-project?rev=65776&view=rev
Log:
Reuse a technique (pioneered for BasicBlocks) of superposing ilist with
its sentinel. This is quite a win when a function really has a basic block.
When the function is just a declaration (and stays so) the old way did not
allocate a sentinel. So this change is most beneficial when the ratio of
function definition to declaration is high. I.e. linkers etc. Incidentally
these are the most resource demanding applications, so I expect that the
reduced malloc traffic, locality and space savings outweigh the cost of
addition of two pointers to Function.
Modified:
llvm/trunk/include/llvm/Function.h
llvm/trunk/lib/VMCore/Function.cpp
Modified: llvm/trunk/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=65776&r1=65775&r2=65776&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Sun Mar 1 10:38:10 2009
@@ -32,12 +32,17 @@
template<> struct ilist_traits<BasicBlock>
: public SymbolTableListTraits<BasicBlock, Function> {
- // createSentinel is used to create a node that marks the end of the list...
- static BasicBlock *createSentinel();
- static void destroySentinel(BasicBlock *BB) { delete BB; }
+ // createSentinel is used to get hold of the node that marks the end of the
+ // list... (same trick used here as in ilist_traits<Instruction>)
+ BasicBlock *createSentinel() const {
+ return const_cast<BasicBlock*>(static_cast<const BasicBlock*>(&Sentinel));
+ }
+ static void destroySentinel(BasicBlock*) {}
static iplist<BasicBlock> &getList(Function *F);
static ValueSymbolTable *getSymTab(Function *ItemParent);
static int getListOffset();
+private:
+ ilist_node<BasicBlock> Sentinel;
};
template<> struct ilist_traits<Argument>
Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=65776&r1=65775&r2=65776&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Sun Mar 1 10:38:10 2009
@@ -22,13 +22,6 @@
#include "llvm/ADT/StringExtras.h"
using namespace llvm;
-BasicBlock *ilist_traits<BasicBlock>::createSentinel() {
- BasicBlock *Ret = BasicBlock::Create();
- // This should not be garbage monitored.
- LeakDetector::removeGarbageObject(Ret);
- return Ret;
-}
-
iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
return F->getBasicBlockList();
}
More information about the llvm-commits
mailing list