[llvm-commits] [llvm] r67872 - in /llvm/trunk: include/llvm/Module.h lib/VMCore/Module.cpp

Gabor Greif ggreif at gmail.com
Fri Mar 27 15:28:33 PDT 2009


Author: ggreif
Date: Fri Mar 27 17:28:33 2009
New Revision: 67872

URL: http://llvm.org/viewvc/llvm-project?rev=67872&view=rev
Log:
"ghostify" the ilist<Function> sentinel

Modified:
    llvm/trunk/include/llvm/Module.h
    llvm/trunk/lib/VMCore/Module.cpp

Modified: llvm/trunk/include/llvm/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=67872&r1=67871&r2=67872&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Module.h (original)
+++ llvm/trunk/include/llvm/Module.h Fri Mar 27 17:28:33 2009
@@ -28,9 +28,20 @@
 
 template<> struct ilist_traits<Function>
   : public SymbolTableListTraits<Function, Module> {
-  // createSentinel is used to create a node that marks the end of the list.
-  static Function *createSentinel();
-  static void destroySentinel(Function *F) { delete F; }
+
+  // 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>)
+  Function *createSentinel() const {
+    return static_cast<Function*>(&Sentinel);
+  }
+  static void destroySentinel(Function*) {}
+
+  Function *provideInitialHead() const { return createSentinel(); }
+  Function *ensureHead(Function*) const { return createSentinel(); }
+  static void noteHead(Function*, Function*) {}
+
+private:
+  mutable ilist_node<Function> Sentinel;
 };
 template<> struct ilist_traits<GlobalVariable>
   : public SymbolTableListTraits<GlobalVariable, Module> {

Modified: llvm/trunk/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=67872&r1=67871&r2=67872&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Module.cpp (original)
+++ llvm/trunk/lib/VMCore/Module.cpp Fri Mar 27 17:28:33 2009
@@ -29,14 +29,6 @@
 // Methods to implement the globals and functions lists.
 //
 
-Function *ilist_traits<Function>::createSentinel() {
-  FunctionType *FTy =
-    FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false);
-  Function *Ret = Function::Create(FTy, GlobalValue::ExternalLinkage);
-  // This should not be garbage monitored.
-  LeakDetector::removeGarbageObject(Ret);
-  return Ret;
-}
 GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() {
   GlobalVariable *Ret = new GlobalVariable(Type::Int32Ty, false,
                                            GlobalValue::ExternalLinkage);





More information about the llvm-commits mailing list