Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,12 @@ void *jl_emit_native_impl(jl_array_t *codeinfos, LLVMOrcThreadSafeModuleRef llvm
continue; // skip any duplicates that accidentally made there way in here (or make this an error?)
if (jl_ir_inlining_cost((jl_value_t*)src) < UINT16_MAX)
params.safepoint_on_entry = false; // ensure we don't block ExpandAtomicModifyPass from inlining this code if applicable
orc::ThreadSafeModule result_m = jl_create_ts_module(name_from_method_instance(jl_get_ci_mi(codeinst)),
params.tsctx, clone.getModuleUnlocked()->getDataLayout(),
Triple(clone.getModuleUnlocked()->getTargetTriple()));
orc::ThreadSafeModule result_m =
jl_create_ts_module(name_from_method_instance(jl_get_ci_mi(codeinst)),
params.tsctx,
clone.getModuleUnlocked()->getDataLayout(),
Triple(clone.getModuleUnlocked()->getTargetTriple()),
clone.getModuleUnlocked());
jl_llvm_functions_t decls;
if (!(params.params->force_emit_all) && jl_atomic_load_relaxed(&codeinst->invoke) == jl_fptr_const_return_addr)
decls.functionObject = "jl_fptr_const_return";
Expand Down
33 changes: 24 additions & 9 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2684,17 +2684,12 @@ static jl_cgval_t convert_julia_type(jl_codectx_t &ctx, const jl_cgval_t &v, jl_
return jl_cgval_t(v, typ, new_tindex);
}

std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &context, const DataLayout &DL, const Triple &triple) JL_NOTSAFEPOINT
std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &context,
const DataLayout &DL, const Triple &triple,
Module *source) JL_NOTSAFEPOINT
{
++ModulesCreated;
auto m = std::make_unique<Module>(name, context);
// According to clang darwin above 10.10 supports dwarfv4
if (!m->getModuleFlag("Dwarf Version")) {
m->addModuleFlag(llvm::Module::Warning, "Dwarf Version", 4);
}
if (!m->getModuleFlag("Debug Info Version"))
m->addModuleFlag(llvm::Module::Warning, "Debug Info Version",
llvm::DEBUG_METADATA_VERSION);
m->setDataLayout(DL);
m->setTargetTriple(triple.str());

Expand All @@ -2705,9 +2700,29 @@ std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &conte
m->setOverrideStackAlignment(16);
}

if (source) {
// Copy module flags from source module
SmallVector<Module::ModuleFlagEntry, 8> Flags;
source->getModuleFlagsMetadata(Flags);
for (const auto &Flag : Flags) {
m->addModuleFlag(Flag.Behavior, Flag.Key->getString(), Flag.Val);
}
// Copy other module-level properties
m->setStackProtectorGuard(source->getStackProtectorGuard());
m->setOverrideStackAlignment(source->getOverrideStackAlignment());
}
else {
// No source: set default Julia flags
// According to clang darwin above 10.10 supports dwarfv4
m->addModuleFlag(llvm::Module::Warning, "Dwarf Version", 4);
m->addModuleFlag(llvm::Module::Warning, "Debug Info Version",
llvm::DEBUG_METADATA_VERSION);

#if defined(JL_DEBUG_BUILD)
m->setStackProtectorGuard("global");
m->setStackProtectorGuard("global");
#endif
}

return m;
}

Expand Down
12 changes: 9 additions & 3 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,16 @@ class JuliaOJIT {
OptSelLayerT OptSelLayer;
};
extern JuliaOJIT *jl_ExecutionEngine;
std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &ctx, const DataLayout &DL, const Triple &triple) JL_NOTSAFEPOINT;
inline orc::ThreadSafeModule jl_create_ts_module(StringRef name, orc::ThreadSafeContext ctx, const DataLayout &DL, const Triple &triple) JL_NOTSAFEPOINT {
std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &ctx,
const DataLayout &DL, const Triple &triple,
Module *source = nullptr) JL_NOTSAFEPOINT;
inline orc::ThreadSafeModule jl_create_ts_module(StringRef name, orc::ThreadSafeContext ctx,
const DataLayout &DL, const Triple &triple,
Module *source = nullptr) JL_NOTSAFEPOINT
{
auto lock = ctx.getLock();
return orc::ThreadSafeModule(jl_create_llvm_module(name, *ctx.getContext(), DL, triple), ctx);
return orc::ThreadSafeModule(
jl_create_llvm_module(name, *ctx.getContext(), DL, triple, source), ctx);
}

Module &jl_codegen_params_t::shared_module() JL_NOTSAFEPOINT {
Expand Down