Don't construct or delete a module on the Linker.
authorRafael Espindola <rafael.espindola@gmail.com>
Sat, 4 May 2013 02:43:00 +0000 (02:43 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sat, 4 May 2013 02:43:00 +0000 (02:43 +0000)
The linker is now responsible only for actually linking the modules, it
is up to the clients to create and destroy them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181098 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Linker.h
lib/Linker/Linker.cpp
tools/lto/LTOCodeGenerator.cpp

index 6761b8e68ed6d5817a3e3f8d345484a2249c4f11..b199a34cbf8b0dc8e96cf7c577dfef59a5fc089b 100644 (file)
@@ -44,13 +44,6 @@ class Linker {
   /// @name Constructors
   /// @{
   public:
-    /// Construct the Linker with an empty module which will be given the
-    /// name \p progname. \p progname will also be used for error messages.
-    /// @brief Construct with empty module
-    Linker(StringRef modulename, ///< name of linker's end-result module
-           LLVMContext &C ///< Context for global info
-    );
-
     /// Construct the Linker with a previously defined module, \p aModule. Use
     /// \p progname for the name of the program in error messages.
     /// @brief Construct with existing module
index c80f8173c3f2bbb4b3ed850370c49b2102cbb581..ab99b98ee040ae2f1c8b8d2ee120c081157b5564 100644 (file)
 #include "llvm/Support/system_error.h"
 using namespace llvm;
 
-Linker::Linker(StringRef modname,
-               LLVMContext& C):
-  Composite(new Module(modname, C)) { }
-
 Linker::Linker(Module* aModule) :
   Composite(aModule) { }
 
 Linker::~Linker() {
-  delete Composite;
 }
index 683a480d3fbb43a174938bf59529653c4eb9b949..de2c1fd4b8d171b5d99ab0e35793a0bda5794145 100644 (file)
@@ -69,7 +69,7 @@ const char* LTOCodeGenerator::getVersionString() {
 
 LTOCodeGenerator::LTOCodeGenerator()
   : _context(getGlobalContext()),
-    _linker("ld-temp.o", _context), _target(NULL),
+    _linker(new Module("ld-temp.o", _context)), _target(NULL),
     _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
     _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
     _nativeObjectFile(NULL) {
@@ -81,6 +81,7 @@ LTOCodeGenerator::LTOCodeGenerator()
 LTOCodeGenerator::~LTOCodeGenerator() {
   delete _target;
   delete _nativeObjectFile;
+  delete _linker.getModule();
 
   for (std::vector<char*>::iterator I = _codegenOptions.begin(),
          E = _codegenOptions.end(); I != E; ++I)