<< " features: " << target_machine_->getTargetFeatureString().str();
}
-SimpleOrcJIT::ModuleHandleT SimpleOrcJIT::AddModule(
+SimpleOrcJIT::VModuleKeyT SimpleOrcJIT::AddModule(
std::unique_ptr<llvm::Module> module) {
- auto handle = cantFail(compile_layer_.addModule(
- execution_session_.allocateVModule(), std::move(module)));
- module_handles_.push_back(handle);
- return handle;
+ auto key = execution_session_.allocateVModule();
+ cantFail(compile_layer_.addModule(key, std::move(module)));
+ module_keys_.push_back(key);
+ return key;
}
-void SimpleOrcJIT::RemoveModule(SimpleOrcJIT::ModuleHandleT handle) {
- module_handles_.erase(
- std::remove(module_handles_.begin(), module_handles_.end(), handle),
- module_handles_.end());
- cantFail(compile_layer_.removeModule(handle));
+void SimpleOrcJIT::RemoveModule(SimpleOrcJIT::VModuleKeyT key) {
+ module_keys_.erase(std::remove(module_keys_.begin(), module_keys_.end(), key),
+ module_keys_.end());
+ cantFail(compile_layer_.removeModule(key));
}
llvm::JITSymbol SimpleOrcJIT::FindSymbol(const std::string& name) {
// Resolve symbol from last module to first, allowing later redefinitions of
// symbols shadow earlier ones.
- for (auto& handle :
- llvm::make_range(module_handles_.rbegin(), module_handles_.rend())) {
+ for (auto& key :
+ llvm::make_range(module_keys_.rbegin(), module_keys_.rend())) {
if (auto symbol =
- compile_layer_.findSymbolIn(handle, mangled_name,
+ compile_layer_.findSymbolIn(key, mangled_name,
/*ExportedSymbolsOnly=*/true)) {
return symbol;
}
std::function<llvm::object::OwningBinary<llvm::object::ObjectFile>(
llvm::Module&)>;
using CompileLayerT = llvm::orc::IRCompileLayer<ObjLayerT, CompileFtor>;
- using ModuleHandleT = CompileLayerT::ModuleHandleT;
+ using VModuleKeyT = llvm::orc::VModuleKey;
// Create a new JIT, targeting the host architecture.
// The |target_options| parameter allows customization of certain code
return target_machine_->getTargetTriple();
}
- // Add a module to the JIT. Returns an opaque handle that can be used to later
+ // Add a module to the JIT. Returns an opaque key that can be used to later
// remove this module.
- ModuleHandleT AddModule(std::unique_ptr<llvm::Module> module);
+ VModuleKeyT AddModule(std::unique_ptr<llvm::Module> module);
// Remove a module from the JIT and free the memory associated with it.
- void RemoveModule(ModuleHandleT handle);
+ void RemoveModule(VModuleKeyT key);
// Get the runtime address of the compiled symbol whose name is given. Returns
// nullptr if the symbol cannot be found.
}
private:
- std::vector<ModuleHandleT> module_handles_;
+ std::vector<VModuleKeyT> module_keys_;
std::unique_ptr<llvm::TargetMachine> target_machine_;
const Disassembler disassembler_;
const llvm::DataLayout data_layout_;