From d257f7d96b414682834f1eb5aa4d9ea00f6761be Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Fri, 27 Mar 2009 22:28:33 +0000 Subject: [PATCH] "ghostify" the ilist sentinel git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67872 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Module.h | 17 ++++++++++++++--- lib/VMCore/Module.cpp | 8 -------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 9d0b2b62f27..9c8607a188a 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -28,9 +28,20 @@ class FunctionType; template<> struct ilist_traits : public SymbolTableListTraits { - // 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) + Function *createSentinel() const { + return static_cast(&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 Sentinel; }; template<> struct ilist_traits : public SymbolTableListTraits { diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 25d297a03e3..a598005e2a8 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -29,14 +29,6 @@ using namespace llvm; // Methods to implement the globals and functions lists. // -Function *ilist_traits::createSentinel() { - FunctionType *FTy = - FunctionType::get(Type::VoidTy, std::vector(), false); - Function *Ret = Function::Create(FTy, GlobalValue::ExternalLinkage); - // This should not be garbage monitored. - LeakDetector::removeGarbageObject(Ret); - return Ret; -} GlobalVariable *ilist_traits::createSentinel() { GlobalVariable *Ret = new GlobalVariable(Type::Int32Ty, false, GlobalValue::ExternalLinkage);