#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/Object/Archive.h"
-#include "llvm/Target/TargetSubtargetInfo.h"
namespace llvm {
OrcMCJITReplacement(std::unique_ptr<RTDyldMemoryManager> MM,
std::unique_ptr<TargetMachine> TM)
- : TM(std::move(TM)), MM(std::move(MM)),
- Mang(this->TM->getSubtargetImpl()->getDataLayout()),
+ : TM(std::move(TM)), MM(std::move(MM)), Mang(this->TM->getDataLayout()),
NotifyObjectLoaded(*this), NotifyFinalized(*this),
ObjectLayer(ObjectLayerT::CreateRTDyldMMFtor(), NotifyObjectLoaded,
NotifyFinalized),
CompileLayer(ObjectLayer, SimpleCompiler(*this->TM)),
LazyEmitLayer(CompileLayer) {
- setDataLayout(this->TM->getSubtargetImpl()->getDataLayout());
+ setDataLayout(this->TM->getDataLayout());
}
void addModule(std::unique_ptr<Module> M) override {
if (!M->getDataLayout())
M->setDataLayout(getDataLayout());
- OwnedModules.push_back(std::move(M));
+ Modules.push_back(std::move(M));
std::vector<Module *> Ms;
- Ms.push_back(&*OwnedModules.back());
+ Ms.push_back(&*Modules.back());
LazyEmitLayer.addModuleSet(std::move(Ms),
llvm::make_unique<ForwardingRTDyldMM>(*this));
}
std::tie(Obj, Buf) = O.takeBinary();
std::vector<std::unique_ptr<object::ObjectFile>> Objs;
Objs.push_back(std::move(Obj));
- ObjectLayer.addObjectSet(std::move(Objs),
- llvm::make_unique<ForwardingRTDyldMM>(*this));
+ auto H =
+ ObjectLayer.addObjectSet(std::move(Objs),
+ llvm::make_unique<ForwardingRTDyldMM>(*this));
+
+ std::vector<std::unique_ptr<MemoryBuffer>> Bufs;
+ Bufs.push_back(std::move(Buf));
+ ObjectLayer.takeOwnershipOfBuffers(H, std::move(Bufs));
}
void addArchive(object::OwningBinary<object::Archive> A) override {
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.