Skip to content
Draft
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
7 changes: 7 additions & 0 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,13 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
return mark_or_box_ccall_result(ctx, ret, retboxed, rt, unionall, static_rt);
}
}
else if (is_libjulia_func(jl_debug_level)) {
assert(lrt == getInt32Ty(ctx.builder.getContext()));
assert(!isVa && !llvmcall && nccallargs == 0);
JL_GC_POP();
auto level = ConstantInt::get(getInt32Ty(ctx.builder.getContext()), jl_options.debug_level);
return mark_or_box_ccall_result(ctx, level, retboxed, rt, unionall, static_rt);
}

jl_cgval_t retval = sig.emit_a_ccall(
ctx,
Expand Down
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
XX(jl_declare_constant) \
XX(jl_defines_or_exports_p) \
XX(jl_deprecate_binding) \
XX(jl_debug_level) \
XX(jl_dlclose) \
XX(jl_dlopen) \
XX(jl_dlsym) \
Expand Down
2 changes: 2 additions & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,8 @@ JL_DLLEXPORT jl_array_t *jl_array_copy(jl_array_t *ary);
JL_DLLEXPORT uintptr_t jl_object_id_(jl_value_t *tv, jl_value_t *v) JL_NOTSAFEPOINT;
JL_DLLEXPORT void jl_set_next_task(jl_task_t *task) JL_NOTSAFEPOINT;

JL_DLLEXPORT int jl_debug_level(void);

// -- synchronization utilities -- //

extern jl_mutex_t typecache_lock;
Expand Down
12 changes: 12 additions & 0 deletions src/llvm-cpufeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ void lowerHaveFMA(Function &intr, Function &caller, CallInst *I) {
return;
}

void lowerDebugLevel(Function &intr, Function &caller, CallInst *I) {
I->replaceAllUsesWith(ConstantInt::get(I->getType(), jl_options.debug_level));
return;
}

bool lowerCPUFeatures(Module &M)
{
SmallVector<Instruction*,6> Materialized;
Expand All @@ -104,6 +109,13 @@ bool lowerCPUFeatures(Module &M)
lowerHaveFMA(F, *I->getParent()->getParent(), I);
Materialized.push_back(I);
}
} else if (FN == "julia.debug_level") {
for (Use &U: F.uses()) {
User *RU = U.getUser();
CallInst *I = cast<CallInst>(RU);
lowerDebugLevel(F, *I->getParent()->getParent(), I);
Materialized.push_back(I);
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/runtime_intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1460,3 +1460,8 @@ JL_DLLEXPORT jl_value_t *jl_have_fma(jl_value_t *typ)
// TODO: run-time feature check?
return jl_false;
}

JL_DLLEXPORT int jl_debug_level()
{
return jl_options.debug_level;
}