Skip to content

Commit

Permalink
LLVM: Activate typed pointers through the API instead of a global opt…
Browse files Browse the repository at this point in the history
…ion. (#51840)

This allows other users of LLVM to use opaque pointers with their
contexts.

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
  • Loading branch information
maleadt and vtjnash committed Oct 25, 2023
1 parent ac2593a commit f3e683d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9196,17 +9196,12 @@ extern "C" void jl_init_llvm(void)
if (clopt && clopt->getNumOccurrences() == 0)
cl::ProvidePositionalOption(clopt, "4", 1);

#if JL_LLVM_VERSION >= 150000
// we want the opaque-pointers to be opt-in, per LLVMContext, for this release
// so change the default value back to pre-14.x, without changing the NumOccurrences flag for it
clopt = llvmopts.lookup("opaque-pointers");
if (clopt && clopt->getNumOccurrences() == 0) {
#ifdef JL_LLVM_OPAQUE_POINTERS
cl::ProvidePositionalOption(clopt, "true", 1);
#else
cl::ProvidePositionalOption(clopt, "false", 1);
#endif
clopt->addOccurrence(1, clopt->ArgStr, "false", true);
}
#endif

jl_ExecutionEngine = new JuliaOJIT();

bool jl_using_gdb_jitevents = false;
Expand Down
6 changes: 6 additions & 0 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,12 @@ JuliaOJIT::JuliaOJIT()
ExternalJD(ES.createBareJITDylib("JuliaExternal")),
ContextPool([](){
auto ctx = std::make_unique<LLVMContext>();
if (!ctx->hasSetOpaquePointersValue())
#ifndef JL_LLVM_OPAQUE_POINTERS
ctx->setOpaquePointers(false);
#else
ctx->setOpaquePointers(true);
#endif
return orc::ThreadSafeContext(std::move(ctx));
}),
#ifdef JL_USE_JITLINK
Expand Down

0 comments on commit f3e683d

Please sign in to comment.