[LLVMdev] misc. patches

Reid Spencer reid at x10sys.com
Mon Dec 13 20:11:51 PST 2004


Morten,

The leaks.patch file introduced a static destructor ordering problem
which lead to garbled output. The comment above those lines of code
indicates why it needs to be the way it is. My bad for committing it in
the first place. Please be careful in the future.

Reid.

On Mon, 2004-12-13 at 05:30, Morten Ofstad wrote:
> Hi,
> 
> here are some minor patches that for various reasons I've not submitted 
> yet - I'm just trying to clear my list of differences before christmas...
> 
> First of all the clear.patch file contains a patch that enables the JIT 
> to drop all global mappings. I need this because when I have N threads I 
> compile N different versions of my functions using different memory 
> areas for global variables - it's also useful in other dynamic 
> recompilation scenarios.
> 
> Next the warnings.patch file contains some minor modification to make 
> Visual Studio shut up (and possibly to make LLVM more 64bit friendly). I 
> chose to typedef a size_type on the LLVM containers that try to mimic 
> the std:: containers, while in the other case I just made a simple cast.
> 
> Finally the leaks.patch file contains a destructor for the 
> JITMemoryManager that frees system memory and a minor modification to 
> how one particular singleton object gets instantiated in CommandLine.cpp 
> to stop the VS leak detector complaining.
> 
> m.
> 
> ______________________________________________________________________
> Index: lib/ExecutionEngine/JIT/JITEmitter.cpp
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp,v
> retrieving revision 1.59
> diff -u -r1.59 JITEmitter.cpp
> --- lib/ExecutionEngine/JIT/JITEmitter.cpp	5 Dec 2004 07:19:16 -0000	1.59
> +++ lib/ExecutionEngine/JIT/JITEmitter.cpp	6 Dec 2004 10:34:21 -0000
> @@ -51,6 +51,7 @@
>      unsigned char *CurStubPtr, *CurFunctionPtr;
>    public:
>      JITMemoryManager();
> +    ~JITMemoryManager();
>      
>      inline unsigned char *allocateStub(unsigned StubSize);
>      inline unsigned char *startFunctionBody();
> @@ -69,6 +70,10 @@
>    CurStubPtr = CurFunctionPtr = FunctionBase;
>  }
>  
> +JITMemoryManager::~JITMemoryManager() {
> +  sys::Memory::ReleaseRWX(MemBlock);
> +}
> +
>  unsigned char *JITMemoryManager::allocateStub(unsigned StubSize) {
>    CurStubPtr -= StubSize;
>    if (CurStubPtr < MemBase) {
> Index: lib/Support/Timer.cpp
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/lib/Support/Timer.cpp,v
> retrieving revision 1.33
> diff -u -r1.33 Timer.cpp
> --- lib/Support/Timer.cpp	19 Nov 2004 04:59:07 -0000	1.33
> +++ lib/Support/Timer.cpp	3 Dec 2004 14:30:24 -0000
> @@ -33,12 +33,10 @@
>  // problem is that a Statistic<> object gets destroyed, which ends up calling
>  // 'GetLibSupportInfoOutputFile()' (below), which calls this function.
>  // LibSupportInfoOutputFilename used to be a global variable, but sometimes it
> -// would get destroyed before the Statistic, causing havoc to ensue.  We "fix"
> -// this by creating the string the first time it is needed and never destroying
> -// it.
> +// would get destroyed before the Statistic, causing havoc to ensue.
>  static std::string &getLibSupportInfoOutputFilename() {
> -  static std::string *LibSupportInfoOutputFilename = new std::string();
> -  return *LibSupportInfoOutputFilename;
> +  static std::string LibSupportInfoOutputFilename;
> +  return LibSupportInfoOutputFilename;
>  }
>  
>  namespace {
> 
> ______________________________________________________________________
> Index: include/llvm/Type.h
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/include/llvm/Type.h,v
> retrieving revision 1.67
> diff -u -r1.67 Type.h
> --- include/llvm/Type.h	19 Nov 2004 16:39:04 -0000	1.67
> +++ include/llvm/Type.h	13 Dec 2004 13:11:57 -0000
> @@ -246,7 +246,8 @@
>  
>    /// getNumContainedTypes - Return the number of types in the derived type.
>    ///
> -  unsigned getNumContainedTypes() const { return ContainedTys.size(); }
> +  typedef std::vector<PATypeHandle>::size_type size_type;
> +  size_type getNumContainedTypes() const { return ContainedTys.size(); }
>  
>    //===--------------------------------------------------------------------===//
>    // Static members exported by the Type class itself.  Useful for getting
> Index: include/llvm/Value.h
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/include/llvm/Value.h,v
> retrieving revision 1.66
> diff -u -r1.66 Value.h
> --- include/llvm/Value.h	27 Oct 2004 16:14:47 -0000	1.66
> +++ include/llvm/Value.h	6 Dec 2004 11:24:02 -0000
> @@ -89,8 +89,9 @@
>    //
>    typedef UseListIteratorWrapper      use_iterator;
>    typedef UseListConstIteratorWrapper use_const_iterator;
> +  typedef iplist<Use>::size_type      size_type;
>  
> -  unsigned           use_size()  const { return Uses.size();  }
> +  size_type          use_size()  const { return Uses.size();  }
>    bool               use_empty() const { return Uses.empty(); }
>    use_iterator       use_begin()       { return Uses.begin(); }
>    use_const_iterator use_begin() const { return Uses.begin(); }
> Index: include/llvm/Support/CommandLine.h
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/include/llvm/Support/CommandLine.h,v
> retrieving revision 1.40
> diff -u -r1.40 CommandLine.h
> --- include/llvm/Support/CommandLine.h	5 Dec 2004 05:17:34 -0000	1.40
> +++ include/llvm/Support/CommandLine.h	6 Dec 2004 10:08:04 -0000
> @@ -435,7 +435,7 @@
>    typedef DataType parser_data_type;
>  
>    // Implement virtual functions needed by generic_parser_base
> -  unsigned getNumOptions() const { return Values.size(); }
> +  unsigned getNumOptions() const { return (unsigned)Values.size(); }
>    const char *getOption(unsigned N) const { return Values[N].first; }
>    const char *getDescription(unsigned N) const {
>      return Values[N].second.second;
> 
> ______________________________________________________________________
> Index: include/llvm/ExecutionEngine/ExecutionEngine.h
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h,v
> retrieving revision 1.30
> diff -u -r1.30 ExecutionEngine.h
> --- include/llvm/ExecutionEngine/ExecutionEngine.h	22 Nov 2004 16:54:54 -0000	1.30
> +++ include/llvm/ExecutionEngine/ExecutionEngine.h	3 Dec 2004 13:50:59 -0000
> @@ -93,6 +93,13 @@
>      }
>    }
>  
> +  /// clearAllGlobalMappings - Clear all global mappings and start over again
> +  /// use in dynamic compilation scenarios when you want to move globals
> +  void clearAllGlobalMappings() {
> +    GlobalAddressMap.clear();
> +    GlobalAddressReverseMap.clear();
> +  }
> +
>    /// updateGlobalMapping - Replace an existing mapping for GV with a new
>    /// address.  This updates both maps as required.
>    void updateGlobalMapping(const GlobalValue *GV, void *Addr) {
> 
> ______________________________________________________________________
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20041213/80cc3914/attachment.sig>


More information about the llvm-dev mailing list