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
signature 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 {
12141214 HashMap<Buf *, TypeStructField *, buf_hash, buf_eql_buf> fields_by_name;
12151215 RootStruct *root_struct;
12161216 uint32_t *host_int_bytes; // available for packed structs, indexed by gen_index
1217 size_t llvm_full_type_queue_index;
12171218
12181219 uint32_t src_field_count;
12191220 uint32_t gen_field_count;
......@@ -1861,6 +1862,7 @@ struct CodeGen {
18611862 ZigList<ErrorTableEntry *> errors_by_index;
18621863 ZigList<CacheHash *> caches_to_release;
18631864 size_t largest_err_name_len;
1865 ZigList<ZigType *> type_resolve_stack;
18641866
18651867 ZigPackage *std_package;
18661868 ZigPackage *panic_package;
src/analyze.cpp+14-1
......@@ -7271,7 +7271,13 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
72717271 di_scope, di_file, line);
72727272
72737273 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 }
72757281 }
72767282
72777283 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
74757481 ZigLLVMReplaceTemporary(g->dbuilder, struct_type->llvm_di_type, replacement_di_type);
74767482 struct_type->llvm_di_type = replacement_di_type;
74777483 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 }
74787491}
74797492
74807493static 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) {
72087208 LLVMSetModuleInlineAsm(g->module, buf_ptr(&g->global_asm));
72097209 }
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
72117217 ZigLLVMDIBuilderFinalize(g->dbuilder);
72127218
72137219 if (g->verbose_llvm_ir) {
src/list.hpp+11
......@@ -74,6 +74,17 @@ struct ZigList {
7474 capacity = better_capacity;
7575 }
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
7788 T *items;
7889 size_t length;
7990 size_t capacity;