MCPcopy Create free account
hub / github.com/apache/arrow / BuildJIT

Function BuildJIT

cpp/src/gandiva/engine.cc:224–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222#endif
223
224Result<std::unique_ptr<llvm::orc::LLJIT>> BuildJIT(
225 llvm::orc::JITTargetMachineBuilder jtmb,
226 std::shared_ptr<llvm::TargetMachine> target_machine,
227 std::optional<std::reference_wrapper<GandivaObjectCache>> object_cache) {
228 auto data_layout = target_machine->createDataLayout();
229
230 llvm::orc::LLJITBuilder jit_builder;
231
232#ifdef JIT_LINK_SUPPORTED
233 ARROW_RETURN_NOT_OK(UseJITLinkIfEnabled(jit_builder));
234#endif
235
236 jit_builder.setJITTargetMachineBuilder(std::move(jtmb));
237#if LLVM_VERSION_MAJOR >= 16
238 jit_builder.setDataLayout(std::make_optional(data_layout));
239#else
240 jit_builder.setDataLayout(llvm::Optional<llvm::DataLayout>(data_layout));
241#endif
242
243 if (object_cache.has_value()) {
244 jit_builder.setCompileFunctionCreator(
245 [tm = std::move(target_machine),
246 &object_cache](llvm::orc::JITTargetMachineBuilder JTMB)
247 -> llvm::Expected<std::unique_ptr<llvm::orc::IRCompileLayer::IRCompiler>> {
248 // after compilation, the object code will be stored into the given object
249 // cache
250 return std::make_unique<llvm::orc::SimpleCompiler>(*tm,
251 &object_cache.value().get());
252 });
253 }
254
255 auto maybe_jit = jit_builder.create();
256 ARROW_ASSIGN_OR_RAISE(auto jit,
257 AsArrowResult(maybe_jit, "Could not create LLJIT instance: "));
258
259 AddProcessSymbol(*jit);
260 return jit;
261}
262
263arrow::Status VerifyAndLinkModule(
264 llvm::Module& dest_module,

Callers

nothing calls this directly

Calls 4

UseJITLinkIfEnabledFunction · 0.85
AddProcessSymbolFunction · 0.85
getMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected