authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-01-08 10:57:39-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-01-08 11:53:51-05:00
logaa65b946711d6f51050977880f64a70f13637e45
tree0a1ca1521b83a90a1909d9b6d60bc0457b1303fa
parent013c7b24d2a2c1f81d2fbcd7c2d07ed582b7acd9
signature Commit is signed but in an unrecognized format.

fix debug info for function pointers

found when testing against LLVM 8 see https://bugs.llvm.org/show_bug.cgi?id=40198

3 files changed, 6 insertions(+), 2 deletions(-)

src/all_types.hpp+1
...@@ -1166,6 +1166,7 @@ struct ZigTypeFn {...@@ -1166,6 +1166,7 @@ struct ZigTypeFn {
1166 FnGenParamInfo *gen_param_info;1166 FnGenParamInfo *gen_param_info;
11671167
1168 LLVMTypeRef raw_type_ref;1168 LLVMTypeRef raw_type_ref;
1169 ZigLLVMDIType *raw_di_type;
11691170
1170 ZigType *bound_fn_parent;1171 ZigType *bound_fn_parent;
1171};1172};
src/analyze.cpp+4-1
...@@ -1220,7 +1220,10 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1220,7 +1220,10 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1220 fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref,1220 fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref,
1221 gen_param_types.items, (unsigned int)gen_param_types.length, fn_type_id->is_var_args);1221 gen_param_types.items, (unsigned int)gen_param_types.length, fn_type_id->is_var_args);
1222 fn_type->type_ref = LLVMPointerType(fn_type->data.fn.raw_type_ref, 0);1222 fn_type->type_ref = LLVMPointerType(fn_type->data.fn.raw_type_ref, 0);
1223 fn_type->di_type = ZigLLVMCreateSubroutineType(g->dbuilder, param_di_types.items, (int)param_di_types.length, 0);1223 fn_type->data.fn.raw_di_type = ZigLLVMCreateSubroutineType(g->dbuilder, param_di_types.items, (int)param_di_types.length, 0);
1224 fn_type->di_type = ZigLLVMCreateDebugPointerType(g->dbuilder, fn_type->data.fn.raw_di_type,
1225 LLVMStoreSizeOfType(g->target_data_ref, fn_type->type_ref),
1226 LLVMABIAlignmentOfType(g->target_data_ref, fn_type->type_ref), "");
1224 }1227 }
12251228
1226 g->fn_type_table.put(&fn_type->data.fn.fn_type_id, fn_type);1229 g->fn_type_table.put(&fn_type->data.fn.fn_type_id, fn_type);
src/codegen.cpp+1-1
...@@ -649,7 +649,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {...@@ -649,7 +649,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
649 ZigLLVMDISubprogram *subprogram = ZigLLVMCreateFunction(g->dbuilder,649 ZigLLVMDISubprogram *subprogram = ZigLLVMCreateFunction(g->dbuilder,
650 fn_di_scope, buf_ptr(&fn_table_entry->symbol_name), "",650 fn_di_scope, buf_ptr(&fn_table_entry->symbol_name), "",
651 import->di_file, line_number,651 import->di_file, line_number,
652 fn_table_entry->type_entry->di_type, is_internal_linkage,652 fn_table_entry->type_entry->data.fn.raw_di_type, is_internal_linkage,
653 is_definition, scope_line, flags, is_optimized, nullptr);653 is_definition, scope_line, flags, is_optimized, nullptr);
654654
655 scope->di_scope = ZigLLVMSubprogramToScope(subprogram);655 scope->di_scope = ZigLLVMSubprogramToScope(subprogram);