[Orc] Remove the OwnedModules list from OrcMCJITReplacement and use
authorLang Hames <lhames@gmail.com>
Mon, 2 Feb 2015 04:34:02 +0000 (04:34 +0000)
committerLang Hames <lhames@gmail.com>
Mon, 2 Feb 2015 04:34:02 +0000 (04:34 +0000)
ExecutionEngine's Modules list instead.

This makes the owned modules visibile to ExecutionEngine. In particular,
it is required for ExecutionEngine::runStaticConstructorsAndDestructors to
work.

Regression tests for Orc (which test this issue) will be committed shortly.

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

lib/ExecutionEngine/Orc/OrcMCJITReplacement.h

index 158d9c785e20604abf71cff154e43abd1c8ec469..838f5dce97f50f75f4d0ab70af2542219ea198ea 100644 (file)
@@ -134,9 +134,9 @@ public:
     if (!M->getDataLayout())
       M->setDataLayout(getDataLayout());
 
     if (!M->getDataLayout())
       M->setDataLayout(getDataLayout());
 
-    OwnedModules.push_back(std::move(M));
+    Modules.push_back(std::move(M));
     std::vector<Module *> Ms;
     std::vector<Module *> Ms;
-    Ms.push_back(&*OwnedModules.back());
+    Ms.push_back(&*Modules.back());
     LazyEmitLayer.addModuleSet(std::move(Ms),
                                llvm::make_unique<ForwardingRTDyldMM>(*this));
   }
     LazyEmitLayer.addModuleSet(std::move(Ms),
                                llvm::make_unique<ForwardingRTDyldMM>(*this));
   }
@@ -302,10 +302,6 @@ private:
   CompileLayerT CompileLayer;
   LazyEmitLayerT LazyEmitLayer;
 
   CompileLayerT CompileLayer;
   LazyEmitLayerT LazyEmitLayer;
 
-  // MCJIT keeps modules alive - we need to do the same for backwards
-  // compatibility.
-  std::vector<std::unique_ptr<Module>> OwnedModules;
-
   // We need to store ObjLayerT::ObjSetHandles for each of the object sets
   // that have been emitted but not yet finalized so that we can forward the
   // mapSectionAddress calls appropriately.
   // We need to store ObjLayerT::ObjSetHandles for each of the object sets
   // that have been emitted but not yet finalized so that we can forward the
   // mapSectionAddress calls appropriately.