Skip to content

Commit

Permalink
debug_enabled -> debug_level, but per emission_context
Browse files Browse the repository at this point in the history
  • Loading branch information
pchintalapudi committed Jun 19, 2023
1 parent 6f5d03b commit 62339ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm
jl_codegen_params_t params(ctxt, std::move(target_info.first), std::move(target_info.second));
params.params = cgparams;
params.imaging = imaging;
params.debug_enabled = debug_default();
params.debug_level = jl_options.debug_level;
params.external_linkage = _external_linkage;
size_t compile_for[] = { jl_typeinf_world, _world };
for (int worlds = 0; worlds < 2; worlds++) {
Expand Down Expand Up @@ -2088,8 +2088,8 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
// differ very significantly from the actual non-imaging mode code.
// // Force imaging mode for names of pointers
// output.imaging = true;
// Force debug info for introspection
output.debug_enabled = true;
// Force max debug info for introspection
output.debug_level = 2;
auto decls = jl_emit_code(m, mi, src, jlrettype, output);
JL_UNLOCK(&jl_codegen_lock); // Might GC

Expand Down
11 changes: 6 additions & 5 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ typedef Instruction TerminatorInst;

void setName(jl_codegen_params_t &params, Value *V, const Twine &Name)
{
if (params.debug_enabled) {
if (params.debug_level) {
V->setName(Name);
}
}
Expand Down Expand Up @@ -7192,9 +7192,9 @@ static jl_llvm_functions_t
// jl_printf(JL_STDERR, "\n*** compiling %s at %s:%d\n\n",
// jl_symbol_name(ctx.name), ctx.file.str().c_str(), toplineno);

bool debug_enabled = ctx.emission_context.debug_enabled;
bool debug_enabled = ctx.emission_context.debug_level != 0;
if (dbgFuncName.empty()) // Should never happen anymore?
debug_enabled = 0;
debug_enabled = false;

// step 2. process var-info lists to see what vars need boxing
int n_ssavalues = jl_is_long(src->ssavaluetypes) ? jl_unbox_long(src->ssavaluetypes) : jl_array_len(src->ssavaluetypes);
Expand Down Expand Up @@ -7375,7 +7375,7 @@ static jl_llvm_functions_t
if (debug_enabled) {
topfile = dbuilder.createFile(ctx.file, ".");
DISubroutineType *subrty;
if (jl_options.debug_level <= 1)
if (ctx.emission_context.debug_level <= 1)
subrty = debuginfo.jl_di_func_null_sig;
else if (!specsig)
subrty = debuginfo.jl_di_func_sig;
Expand All @@ -7396,7 +7396,7 @@ static jl_llvm_functions_t
);
topdebugloc = DILocation::get(ctx.builder.getContext(), toplineno, 0, SP, NULL);
f->setSubprogram(SP);
if (jl_options.debug_level >= 2) {
if (ctx.emission_context.debug_level >= 2) {
const bool AlwaysPreserve = true;
// Go over all arguments and local variables and initialize their debug information
for (i = 0; i < nreq; i++) {
Expand Down Expand Up @@ -8754,6 +8754,7 @@ jl_llvm_functions_t jl_emit_codeinst(
if (// keep code when keeping everything
!(JL_DELETE_NON_INLINEABLE) ||
// aggressively keep code when debugging level >= 2
// note that this uses the global jl_options.debug_level, not the local emission_ctx.debug_level
jl_options.debug_level > 1) {
// update the stored code
if (inferred != (jl_value_t*)src) {
Expand Down
4 changes: 2 additions & 2 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static jl_callptr_t _jl_compile_codeinst(
params.cache = true;
params.world = world;
params.imaging = imaging_default();
params.debug_enabled = debug_default();
params.debug_level = jl_options.debug_level;
jl_workqueue_t emitted;
{
orc::ThreadSafeModule result_m =
Expand Down Expand Up @@ -361,7 +361,7 @@ int jl_compile_extern_c_impl(LLVMOrcThreadSafeModuleRef llvmmod, void *p, void *
});
jl_codegen_params_t params(into->getContext(), std::move(target_info.first), std::move(target_info.second));
params.imaging = imaging_default();
params.debug_enabled = debug_default();
params.debug_level = jl_options.debug_level;
if (pparams == NULL)
pparams = &params;
assert(pparams->tsctx.getContext() == into->getContext().getContext());
Expand Down
6 changes: 1 addition & 5 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ static inline bool imaging_default() JL_NOTSAFEPOINT {
return jl_options.image_codegen || (jl_generating_output() && (!jl_options.incremental || jl_options.use_pkgimages));
}

static inline bool debug_default() JL_NOTSAFEPOINT {
return jl_options.debug_level > 0;
}

struct OptimizationOptions {
bool lower_intrinsics;
bool dump_native;
Expand Down Expand Up @@ -241,7 +237,7 @@ typedef struct _jl_codegen_params_t {
bool cache = false;
bool external_linkage = false;
bool imaging;
bool debug_enabled;
int debug_level;
_jl_codegen_params_t(orc::ThreadSafeContext ctx, DataLayout DL, Triple triple)
: tsctx(std::move(ctx)), tsctx_lock(tsctx.getLock()),
DL(std::move(DL)), TargetTriple(std::move(triple)), imaging(imaging_default()) {}
Expand Down

0 comments on commit 62339ba

Please sign in to comment.