authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-12-23 18:22:30-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-12-23 18:22:30-05:00
log75d142c3c78ef786801dcf85f44d16a6530f02d2
tree046e03de2fc156bbf45379f8d2b58c643edfb249
parent94424e3fa6d0bbcfb9bbaaff040913d5445fdd51

llvm8: fix ZigLLVMCreateFunction


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) {
643643 unsigned line_number = (unsigned)(fn_table_entry->proto_node->line == 0) ?
644644 0 : (fn_table_entry->proto_node->line + 1);
645645 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);
646650 unsigned flags = 0;
647651 ZigLLVMDIScope *fn_di_scope = get_di_scope(g, scope->parent);
648652 assert(fn_di_scope != nullptr);
649653 ZigLLVMDISubprogram *subprogram = ZigLLVMCreateFunction(g->dbuilder,
650654 fn_di_scope, buf_ptr(&fn_table_entry->symbol_name), "",
651655 import->di_file, line_number,
652 fn_table_entry->type_entry->di_type,
653 scope_line, flags, nullptr);
656 fn_table_entry->type_entry->di_type, is_internal_linkage,
657 is_definition, scope_line, flags, is_optimized, nullptr);
654658
655659 scope->di_scope = ZigLLVMSubprogramToScope(subprogram);
656660 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
594594
595595ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope,
596596 const char *name, const char *linkage_name, ZigLLVMDIFile *file, unsigned lineno,
597 ZigLLVMDIType *fn_di_type, unsigned scope_line,
598 unsigned flags, ZigLLVMDISubprogram *decl_subprogram)
597 ZigLLVMDIType *fn_di_type, bool is_local_to_unit, bool is_definition, unsigned scope_line,
598 unsigned flags, bool is_optimized, ZigLLVMDISubprogram *decl_subprogram)
599599{
600600 DISubroutineType *di_sub_type = static_cast<DISubroutineType*>(reinterpret_cast<DIType*>(fn_di_type));
601601 assert(flags == 0);
......@@ -607,7 +607,7 @@ ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMD
607607 di_sub_type,
608608 scope_line,
609609 DINode::FlagZero,
610 DISubprogram::SPFlagZero,
610 DISubprogram::toSPFlags(is_local_to_unit, is_definition, is_optimized),
611611 nullptr,
612612 reinterpret_cast<DISubprogram *>(decl_subprogram),
613613 nullptr);
src/zig_llvm.h+3-2
......@@ -188,8 +188,9 @@ ZIG_EXTERN_C struct ZigLLVMDIFile *ZigLLVMCreateFile(struct ZigLLVMDIBuilder *di
188188
189189ZIG_EXTERN_C struct ZigLLVMDISubprogram *ZigLLVMCreateFunction(struct ZigLLVMDIBuilder *dibuilder,
190190 struct ZigLLVMDIScope *scope, const char *name, const char *linkage_name, struct ZigLLVMDIFile *file,
191 unsigned lineno, struct ZigLLVMDIType *fn_di_type,
192 unsigned scope_line, unsigned flags, struct ZigLLVMDISubprogram *decl_subprogram);
191 unsigned lineno, struct ZigLLVMDIType *fn_di_type, bool is_local_to_unit, bool is_definition,
192 unsigned scope_line, unsigned flags, bool is_optimized, struct ZigLLVMDISubprogram *decl_subprogram);
193
193194
194195ZIG_EXTERN_C void ZigLLVMFnSetSubprogram(LLVMValueRef fn, struct ZigLLVMDISubprogram *subprogram);
195196