[llvm-commits] [llvm] r65778 - in /llvm/trunk: include/llvm/Function.h lib/VMCore/Function.cpp

Gabor Greif ggreif at gmail.com
Sun Mar 1 09:13:15 PST 2009


Author: ggreif
Date: Sun Mar  1 11:13:15 2009
New Revision: 65778

URL: http://llvm.org/viewvc/llvm-project?rev=65778&view=rev
Log:
Another sentinel optimization. This one should always
be a win, since almost every interesting function has at least one Argument.

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=65778&r1=65777&r2=65778&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Sun Mar  1 11:13:15 2009
@@ -48,12 +48,15 @@
 template<> struct ilist_traits<Argument>
   : public SymbolTableListTraits<Argument, Function> {
 
-  // createSentinel is used to create a node that marks the end of the list...
-  static Argument *createSentinel();
-  static void destroySentinel(Argument *A) { delete A; }
+  Argument *createSentinel() const {
+    return const_cast<Argument*>(static_cast<const Argument*>(&Sentinel));
+  }
+  static void destroySentinel(Argument*) {}
   static iplist<Argument> &getList(Function *F);
   static ValueSymbolTable *getSymTab(Function *ItemParent);
   static int getListOffset();
+private:
+  ilist_node<Argument> Sentinel;
 };
 
 class Function : public GlobalValue, public Annotable,

Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=65778&r1=65777&r2=65778&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Sun Mar  1 11:13:15 2009
@@ -26,13 +26,6 @@
   return F->getBasicBlockList();
 }
 
-Argument *ilist_traits<Argument>::createSentinel() {
-  Argument *Ret = new Argument(Type::Int32Ty);
-  // This should not be garbage monitored.
-  LeakDetector::removeGarbageObject(Ret);
-  return Ret;
-}
-
 iplist<Argument> &ilist_traits<Argument>::getList(Function *F) {
   return F->getArgumentList();
 }





More information about the llvm-commits mailing list