authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-29 10:24:24-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-29 10:29:48-04:00
log94bbb46ca602be0ea0df97c207a98734ac459a0f
tree93199fdd18a2b788aa54667edcd67061e6bd779f
parent834a789bb96e65749299ce6c6e57688d699145eb
signaturelock-open Commit is signed but in an unrecognized format.

fix not fully resolving debug info for structs causing llvm error


4 files changed, 33 insertions(+), 1 deletions(-)

src/all_types.hpp+2
...@@ -1214,6 +1214,7 @@ struct ZigTypeStruct {...@@ -1214,6 +1214,7 @@ struct ZigTypeStruct {
1214 HashMap<Buf *, TypeStructField *, buf_hash, buf_eql_buf> fields_by_name;1214 HashMap<Buf *, TypeStructField *, buf_hash, buf_eql_buf> fields_by_name;
1215 RootStruct *root_struct;1215 RootStruct *root_struct;
1216 uint32_t *host_int_bytes; // available for packed structs, indexed by gen_index1216 uint32_t *host_int_bytes; // available for packed structs, indexed by gen_index
1217 size_t llvm_full_type_queue_index;
12171218
1218 uint32_t src_field_count;1219 uint32_t src_field_count;
1219 uint32_t gen_field_count;1220 uint32_t gen_field_count;
...@@ -1861,6 +1862,7 @@ struct CodeGen {...@@ -1861,6 +1862,7 @@ struct CodeGen {
1861 ZigList<ErrorTableEntry *> errors_by_index;1862 ZigList<ErrorTableEntry *> errors_by_index;
1862 ZigList<CacheHash *> caches_to_release;1863 ZigList<CacheHash *> caches_to_release;
1863 size_t largest_err_name_len;1864 size_t largest_err_name_len;
1865 ZigList<ZigType *> type_resolve_stack;
18641866
1865 ZigPackage *std_package;1867 ZigPackage *std_package;
1866 ZigPackage *panic_package;1868 ZigPackage *panic_package;
src/analyze.cpp+14-1
...@@ -7271,7 +7271,13 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS...@@ -7271,7 +7271,13 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
7271 di_scope, di_file, line);7271 di_scope, di_file, line);
72727272
7273 struct_type->data.structure.resolve_status = ResolveStatusLLVMFwdDecl;7273 struct_type->data.structure.resolve_status = ResolveStatusLLVMFwdDecl;
7274 if (ResolveStatusLLVMFwdDecl >= wanted_resolve_status) return;7274 if (ResolveStatusLLVMFwdDecl >= wanted_resolve_status) {
7275 struct_type->data.structure.llvm_full_type_queue_index = g->type_resolve_stack.length;
7276 g->type_resolve_stack.append(struct_type);
7277 return;
7278 } else {
7279 struct_type->data.structure.llvm_full_type_queue_index = SIZE_MAX;
7280 }
7275 }7281 }
72767282
7277 size_t field_count = struct_type->data.structure.src_field_count;7283 size_t field_count = struct_type->data.structure.src_field_count;
...@@ -7475,6 +7481,13 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS...@@ -7475,6 +7481,13 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
7475 ZigLLVMReplaceTemporary(g->dbuilder, struct_type->llvm_di_type, replacement_di_type);7481 ZigLLVMReplaceTemporary(g->dbuilder, struct_type->llvm_di_type, replacement_di_type);
7476 struct_type->llvm_di_type = replacement_di_type;7482 struct_type->llvm_di_type = replacement_di_type;
7477 struct_type->data.structure.resolve_status = ResolveStatusLLVMFull;7483 struct_type->data.structure.resolve_status = ResolveStatusLLVMFull;
7484 if (struct_type->data.structure.llvm_full_type_queue_index != SIZE_MAX) {
7485 ZigType *last = g->type_resolve_stack.last();
7486 assert(last->id == ZigTypeIdStruct);
7487 last->data.structure.llvm_full_type_queue_index = struct_type->data.structure.llvm_full_type_queue_index;
7488 g->type_resolve_stack.swap_remove(struct_type->data.structure.llvm_full_type_queue_index);
7489 struct_type->data.structure.llvm_full_type_queue_index = SIZE_MAX;
7490 }
7478}7491}
74797492
7480static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type, ResolveStatus wanted_resolve_status) {7493static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type, ResolveStatus wanted_resolve_status) {
src/codegen.cpp+6
...@@ -7208,6 +7208,12 @@ static void do_code_gen(CodeGen *g) {...@@ -7208,6 +7208,12 @@ static void do_code_gen(CodeGen *g) {
7208 LLVMSetModuleInlineAsm(g->module, buf_ptr(&g->global_asm));7208 LLVMSetModuleInlineAsm(g->module, buf_ptr(&g->global_asm));
7209 }7209 }
72107210
7211 while (g->type_resolve_stack.length != 0) {
7212 ZigType *ty = g->type_resolve_stack.last();
7213 if (type_resolve(g, ty, ResolveStatusLLVMFull))
7214 zig_unreachable();
7215 }
7216
7211 ZigLLVMDIBuilderFinalize(g->dbuilder);7217 ZigLLVMDIBuilderFinalize(g->dbuilder);
72127218
7213 if (g->verbose_llvm_ir) {7219 if (g->verbose_llvm_ir) {
src/list.hpp+11
...@@ -74,6 +74,17 @@ struct ZigList {...@@ -74,6 +74,17 @@ struct ZigList {
74 capacity = better_capacity;74 capacity = better_capacity;
75 }75 }
7676
77 T swap_remove(size_t index) {
78 if (length - 1 == index) return pop();
79
80 assert(index != SIZE_MAX);
81 assert(index < length);
82
83 T old_item = items[index];
84 items[index] = pop();
85 return old_item;
86 }
87
77 T *items;88 T *items;
78 size_t length;89 size_t length;
79 size_t capacity;90 size_t capacity;