| author | |
| committer | |
| log | 75d142c3c78ef786801dcf85f44d16a6530f02d2 |
| tree | 046e03de2fc156bbf45379f8d2b58c643edfb249 |
| parent | 94424e3fa6d0bbcfb9bbaaff040913d5445fdd51 |
3 files changed, 12 insertions(+), 7 deletions(-)
src/codegen.cpp+6-2| ... | @@ -643,14 +643,18 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { | ... | @@ -643,14 +643,18 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { |
| 643 | unsigned line_number = (unsigned)(fn_table_entry->proto_node->line == 0) ? | 643 | unsigned line_number = (unsigned)(fn_table_entry->proto_node->line == 0) ? |
| 644 | 0 : (fn_table_entry->proto_node->line + 1); | 644 | 0 : (fn_table_entry->proto_node->line + 1); |
| 645 | unsigned scope_line = line_number; | 645 | unsigned scope_line = line_number; |
| 646 | bool is_definition = fn_table_entry->body_node != nullptr; | ||
| 647 | bool is_optimized = g->build_mode != BuildModeDebug; | ||
| 648 | bool is_internal_linkage = (fn_table_entry->body_node != nullptr && | ||
| 649 | fn_table_entry->export_list.length == 0); | ||
| 646 | unsigned flags = 0; | 650 | unsigned flags = 0; |
| 647 | ZigLLVMDIScope *fn_di_scope = get_di_scope(g, scope->parent); | 651 | ZigLLVMDIScope *fn_di_scope = get_di_scope(g, scope->parent); |
| 648 | assert(fn_di_scope != nullptr); | 652 | assert(fn_di_scope != nullptr); |
| 649 | ZigLLVMDISubprogram *subprogram = ZigLLVMCreateFunction(g->dbuilder, | 653 | ZigLLVMDISubprogram *subprogram = ZigLLVMCreateFunction(g->dbuilder, |
| 650 | fn_di_scope, buf_ptr(&fn_table_entry->symbol_name), "", | 654 | fn_di_scope, buf_ptr(&fn_table_entry->symbol_name), "", |
| 651 | import->di_file, line_number, | 655 | import->di_file, line_number, |
| 652 | fn_table_entry->type_entry->di_type, | 656 | fn_table_entry->type_entry->di_type, is_internal_linkage, |
| 653 | scope_line, flags, nullptr); | 657 | is_definition, scope_line, flags, is_optimized, nullptr); |
| 654 | 658 | ||
| 655 | scope->di_scope = ZigLLVMSubprogramToScope(subprogram); | 659 | scope->di_scope = ZigLLVMSubprogramToScope(subprogram); |
| 656 | ZigLLVMFnSetSubprogram(fn_llvm_value(g, fn_table_entry), subprogram); | 660 | ZigLLVMFnSetSubprogram(fn_llvm_value(g, fn_table_entry), subprogram); |
src/zig_llvm.cpp+3-3| ... | @@ -594,8 +594,8 @@ ZigLLVMDIFile *ZigLLVMCreateFile(ZigLLVMDIBuilder *dibuilder, const char *filena | ... | @@ -594,8 +594,8 @@ ZigLLVMDIFile *ZigLLVMCreateFile(ZigLLVMDIBuilder *dibuilder, const char *filena |
| 594 | 594 | ||
| 595 | ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope, | 595 | ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope, |
| 596 | const char *name, const char *linkage_name, ZigLLVMDIFile *file, unsigned lineno, | 596 | const char *name, const char *linkage_name, ZigLLVMDIFile *file, unsigned lineno, |
| 597 | ZigLLVMDIType *fn_di_type, unsigned scope_line, | 597 | ZigLLVMDIType *fn_di_type, bool is_local_to_unit, bool is_definition, unsigned scope_line, |
| 598 | unsigned flags, ZigLLVMDISubprogram *decl_subprogram) | 598 | unsigned flags, bool is_optimized, ZigLLVMDISubprogram *decl_subprogram) |
| 599 | { | 599 | { |
| 600 | DISubroutineType *di_sub_type = static_cast<DISubroutineType*>(reinterpret_cast<DIType*>(fn_di_type)); | 600 | DISubroutineType *di_sub_type = static_cast<DISubroutineType*>(reinterpret_cast<DIType*>(fn_di_type)); |
| 601 | assert(flags == 0); | 601 | assert(flags == 0); |
| ... | @@ -607,7 +607,7 @@ ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMD | ... | @@ -607,7 +607,7 @@ ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMD |
| 607 | di_sub_type, | 607 | di_sub_type, |
| 608 | scope_line, | 608 | scope_line, |
| 609 | DINode::FlagZero, | 609 | DINode::FlagZero, |
| 610 | DISubprogram::SPFlagZero, | 610 | DISubprogram::toSPFlags(is_local_to_unit, is_definition, is_optimized), |
| 611 | nullptr, | 611 | nullptr, |
| 612 | reinterpret_cast<DISubprogram *>(decl_subprogram), | 612 | reinterpret_cast<DISubprogram *>(decl_subprogram), |
| 613 | nullptr); | 613 | nullptr); |
src/zig_llvm.h+3-2| ... | @@ -188,8 +188,9 @@ ZIG_EXTERN_C struct ZigLLVMDIFile *ZigLLVMCreateFile(struct ZigLLVMDIBuilder *di | ... | @@ -188,8 +188,9 @@ ZIG_EXTERN_C struct ZigLLVMDIFile *ZigLLVMCreateFile(struct ZigLLVMDIBuilder *di |
| 188 | 188 | ||
| 189 | ZIG_EXTERN_C struct ZigLLVMDISubprogram *ZigLLVMCreateFunction(struct ZigLLVMDIBuilder *dibuilder, | 189 | ZIG_EXTERN_C struct ZigLLVMDISubprogram *ZigLLVMCreateFunction(struct ZigLLVMDIBuilder *dibuilder, |
| 190 | struct ZigLLVMDIScope *scope, const char *name, const char *linkage_name, struct ZigLLVMDIFile *file, | 190 | struct ZigLLVMDIScope *scope, const char *name, const char *linkage_name, struct ZigLLVMDIFile *file, |
| 191 | unsigned lineno, struct ZigLLVMDIType *fn_di_type, | 191 | unsigned lineno, struct ZigLLVMDIType *fn_di_type, bool is_local_to_unit, bool is_definition, |
| 192 | unsigned scope_line, unsigned flags, struct ZigLLVMDISubprogram *decl_subprogram); | 192 | unsigned scope_line, unsigned flags, bool is_optimized, struct ZigLLVMDISubprogram *decl_subprogram); |
| 193 | |||
| 193 | 194 | ||
| 194 | ZIG_EXTERN_C void ZigLLVMFnSetSubprogram(LLVMValueRef fn, struct ZigLLVMDISubprogram *subprogram); | 195 | ZIG_EXTERN_C void ZigLLVMFnSetSubprogram(LLVMValueRef fn, struct ZigLLVMDISubprogram *subprogram); |
| 195 | 196 |