Skip to content

Commit

Permalink
Rename arg_o to emit_debug_info
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirumalai-Shaktivel committed Nov 2, 2022
1 parent 8ec42d2 commit c6aa952
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ int main(int argc, char *argv[])
app.add_option("-I", compiler_options.import_path, "Specify the path"
"to look for the module")->allow_extra_args(false);
// app.add_option("-J", arg_J, "Where to save mod files");
app.add_flag("-g", compiler_options.arg_g, "Compile with debugging information");
app.add_flag("-g", compiler_options.emit_debug_info, "Compile with debugging information");
// app.add_option("-D", compiler_options.c_preprocessor_defines, "Define <macro>=<value> (or 1 if <value> omitted)")->allow_extra_args(false);
app.add_flag("--version", arg_version, "Display compiler version information");

Expand Down
32 changes: 16 additions & 16 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
std::unique_ptr<llvm::Module> module;
std::unique_ptr<llvm::IRBuilder<>> builder;
Platform platform;
bool enable_debug_info;
bool emit_debug_info;
Allocator &al;

llvm::Value *tmp;
Expand Down Expand Up @@ -239,11 +239,11 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
llvm::DIFile *debug_Unit;

ASRToLLVMVisitor(Allocator &al, llvm::LLVMContext &context, Platform platform,
bool enable_debug_info, diag::Diagnostics &diagnostics) :
bool emit_debug_info, diag::Diagnostics &diagnostics) :
diag{diagnostics},
context(context),
builder(std::make_unique<llvm::IRBuilder<>>(context)),
platform{platform}, enable_debug_info{enable_debug_info},
platform{platform}, emit_debug_info{emit_debug_info},
al{al},
prototype_only(false),
llvm_utils(std::make_unique<LLVMUtils>(context, builder.get())),
Expand Down Expand Up @@ -1147,7 +1147,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
module = std::make_unique<llvm::Module>("LFortran", context);
module->setDataLayout("");

if (enable_debug_info) {
if (emit_debug_info) {
DBuilder = std::make_unique<llvm::DIBuilder>(*module);
debug_CU = DBuilder->createCompileUnit(
llvm::dwarf::DW_LANG_C, DBuilder->createFile("xxexpr.py", "/yy/"),
Expand Down Expand Up @@ -2249,7 +2249,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
llvm::Function::ExternalLinkage, "main", module.get());
llvm::BasicBlock *BB = llvm::BasicBlock::Create(context,
".entry", F);
if (enable_debug_info) {
if (emit_debug_info) {
llvm::DISubprogram *SP;
debug_emit_function(x, SP);
F->setSubprogram(SP);
Expand All @@ -2266,7 +2266,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
dict_api_sc->set_is_dict_present(is_dict_present_copy_sc);

// Finalize the debug info.
if (enable_debug_info) DBuilder->finalize();
if (emit_debug_info) DBuilder->finalize();
}

/*
Expand Down Expand Up @@ -2599,7 +2599,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
}
}
llvm::AllocaInst *ptr = builder->CreateAlloca(type, nullptr, v->m_name);
if (enable_debug_info) {
if (emit_debug_info) {
// Reset the debug location
builder->SetCurrentDebugLocation(nullptr);
uint64_t LineNo = v->base.base.loc.first;
Expand Down Expand Up @@ -3183,7 +3183,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
dict_api_sc->set_is_dict_present(is_dict_present_copy_sc);

// Finalize the debug info.
if (enable_debug_info) DBuilder->finalize();
if (emit_debug_info) DBuilder->finalize();
}

void instantiate_function(const ASR::Function_t &x){
Expand Down Expand Up @@ -3218,19 +3218,19 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
llvm::Function::ExternalLinkage, fn_name, module.get());

// Add Debugging information to the LLVM function F
if (enable_debug_info) {
if (emit_debug_info) {
debug_emit_function(x, SP);
F->setSubprogram(SP);
}
} else {
uint32_t old_h = llvm_symtab_fn_names[fn_name];
F = llvm_symtab_fn[old_h];
if (enable_debug_info) {
if (emit_debug_info) {
SP = (llvm::DISubprogram*) llvm_symtab_fn_discope[old_h];
}
}
llvm_symtab_fn[h] = F;
if (enable_debug_info) llvm_symtab_fn_discope[h] = SP;
if (emit_debug_info) llvm_symtab_fn_discope[h] = SP;

// Instantiate (pre-declare) all nested interfaces
for (auto &item : x.m_symtab->get_scope()) {
Expand Down Expand Up @@ -3427,12 +3427,12 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
parent_function = &x;
parent_function_hash = h;
llvm::Function* F = llvm_symtab_fn[h];
if (enable_debug_info) debug_current_scope = llvm_symtab_fn_discope[h];
if (emit_debug_info) debug_current_scope = llvm_symtab_fn_discope[h];
proc_return = llvm::BasicBlock::Create(context, "return");
llvm::BasicBlock *BB = llvm::BasicBlock::Create(context,
".entry", F);
builder->SetInsertPoint(BB);
if (enable_debug_info) debug_emit_loc(x);
if (emit_debug_info) debug_emit_loc(x);
declare_args(x, *F);
declare_local_vars(x);
}
Expand Down Expand Up @@ -3713,7 +3713,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
}

void visit_Assignment(const ASR::Assignment_t &x) {
if (enable_debug_info) debug_emit_loc(x);
if (emit_debug_info) debug_emit_loc(x);
if( x.m_overloaded ) {
this->visit_stmt(*x.m_overloaded);
return ;
Expand Down Expand Up @@ -6012,7 +6012,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
}

void visit_SubroutineCall(const ASR::SubroutineCall_t &x) {
if (enable_debug_info) debug_emit_loc(x);
if (emit_debug_info) debug_emit_loc(x);
if( ASRUtils::is_intrinsic_optimization(x.m_name) ) {
ASR::Function_t* routine = ASR::down_cast<ASR::Function_t>(
ASRUtils::symbol_get_past_external(x.m_name));
Expand Down Expand Up @@ -6359,7 +6359,7 @@ Result<std::unique_ptr<LLVMModule>> asr_to_llvm(ASR::TranslationUnit_t &asr,
#if LLVM_VERSION_MAJOR >= 15
context.setOpaquePointers(false);
#endif
ASRToLLVMVisitor v(al, context, co.platform, co.arg_g, diagnostics);
ASRToLLVMVisitor v(al, context, co.platform, co.emit_debug_info, diagnostics);
LCompilers::PassOptions pass_options;
pass_options.run_fun = run_fn;
pass_options.always_run = false;
Expand Down
2 changes: 1 addition & 1 deletion src/libasr/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct CompilerOptions {
bool implicit_interface = false;
std::string target = "";
std::string arg_o = "";
bool arg_g = false;
bool emit_debug_info = false;
std::string import_path = "";
Platform platform;

Expand Down

0 comments on commit c6aa952

Please sign in to comment.