authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-02 17:12:09-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-02 18:31:19-04:00
log4c38a8cce17979a9e8ce15c8ccfe1b7ccdb59832
tree8d1cb172f37e2a2af6b16fce862e71daea5dc394
parent5aee17e888c0db7ed0d220334f3adeff6e323cb2
signaturelock-open Commit is signed but in an unrecognized format.

more regression fixes. empty test passes again


3 files changed, 62 insertions(+), 43 deletions(-)

src/analyze.cpp+54-39
......@@ -6252,53 +6252,55 @@ static void resolve_llvm_types_slice(CodeGen *g, ZigType *type, ResolveStatus wa
62526252 ZigType *ptr_type = type->data.structure.fields[slice_ptr_index].type_entry;
62536253 ZigType *child_type = ptr_type->data.pointer.child_type;
62546254 ZigType *usize_type = g->builtin_types.entry_usize;
6255 LLVMTypeRef usize_llvm_type = get_llvm_type(g, usize_type);
6256 ZigLLVMDIType *usize_llvm_di_type = get_llvm_di_type(g, usize_type);
6257 ZigLLVMDIScope *compile_unit_scope = ZigLLVMCompileUnitToScope(g->compile_unit);
6258 ZigLLVMDIFile *di_file = nullptr;
6259 unsigned line = 0;
62606255
6261 if (type->data.structure.resolve_status < ResolveStatusLLVMFwdDecl) {
6262 bool done = false;
6263 if (ptr_type->data.pointer.is_const || ptr_type->data.pointer.is_volatile ||
6264 ptr_type->data.pointer.explicit_alignment != 0 || ptr_type->data.pointer.allow_zero)
6256 bool done = false;
6257 if (ptr_type->data.pointer.is_const || ptr_type->data.pointer.is_volatile ||
6258 ptr_type->data.pointer.explicit_alignment != 0 || ptr_type->data.pointer.allow_zero)
6259 {
6260 ZigType *peer_ptr_type = get_pointer_to_type_extra(g, child_type, false, false,
6261 PtrLenUnknown, 0, 0, 0, false);
6262 ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type);
6263
6264 assertNoError(type_resolve(g, peer_slice_type, wanted_resolve_status));
6265 type->llvm_type = peer_slice_type->llvm_type;
6266 type->llvm_di_type = peer_slice_type->llvm_di_type;
6267 type->data.structure.resolve_status = peer_slice_type->data.structure.resolve_status;
6268 done = true;
6269 }
6270
6271 // If the child type is []const T then we need to make sure the type ref
6272 // and debug info is the same as if the child type were []T.
6273 if (is_slice(child_type)) {
6274 ZigType *child_ptr_type = child_type->data.structure.fields[slice_ptr_index].type_entry;
6275 assert(child_ptr_type->id == ZigTypeIdPointer);
6276 if (child_ptr_type->data.pointer.is_const || child_ptr_type->data.pointer.is_volatile ||
6277 child_ptr_type->data.pointer.explicit_alignment != 0 || child_ptr_type->data.pointer.allow_zero)
62656278 {
6266 ZigType *peer_ptr_type = get_pointer_to_type_extra(g, child_type, false, false,
6279 ZigType *grand_child_type = child_ptr_type->data.pointer.child_type;
6280 ZigType *bland_child_ptr_type = get_pointer_to_type_extra(g, grand_child_type, false, false,
6281 PtrLenUnknown, 0, 0, 0, false);
6282 ZigType *bland_child_slice = get_slice_type(g, bland_child_ptr_type);
6283 ZigType *peer_ptr_type = get_pointer_to_type_extra(g, bland_child_slice, false, false,
62676284 PtrLenUnknown, 0, 0, 0, false);
62686285 ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type);
62696286
6270 type->llvm_type = get_llvm_type(g, peer_slice_type);
6271 type->llvm_di_type = get_llvm_di_type(g, peer_slice_type);
6287 assertNoError(type_resolve(g, peer_slice_type, wanted_resolve_status));
6288 type->llvm_type = peer_slice_type->llvm_type;
6289 type->llvm_di_type = peer_slice_type->llvm_di_type;
6290 type->data.structure.resolve_status = peer_slice_type->data.structure.resolve_status;
62726291 done = true;
62736292 }
6293 }
62746294
6275 // If the child type is []const T then we need to make sure the type ref
6276 // and debug info is the same as if the child type were []T.
6277 if (is_slice(child_type)) {
6278 ZigType *child_ptr_type = child_type->data.structure.fields[slice_ptr_index].type_entry;
6279 assert(child_ptr_type->id == ZigTypeIdPointer);
6280 if (child_ptr_type->data.pointer.is_const || child_ptr_type->data.pointer.is_volatile ||
6281 child_ptr_type->data.pointer.explicit_alignment != 0 || child_ptr_type->data.pointer.allow_zero)
6282 {
6283 ZigType *grand_child_type = child_ptr_type->data.pointer.child_type;
6284 ZigType *bland_child_ptr_type = get_pointer_to_type_extra(g, grand_child_type, false, false,
6285 PtrLenUnknown, 0, 0, 0, false);
6286 ZigType *bland_child_slice = get_slice_type(g, bland_child_ptr_type);
6287 ZigType *peer_ptr_type = get_pointer_to_type_extra(g, bland_child_slice, false, false,
6288 PtrLenUnknown, 0, 0, 0, false);
6289 ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type);
6290
6291 type->llvm_type = get_llvm_type(g, peer_slice_type);
6292 type->llvm_di_type = get_llvm_di_type(g, peer_slice_type);
6293 done = true;
6294 }
6295 }
6295 if (done) return;
62966296
6297 if (done) {
6298 type->data.structure.resolve_status = ResolveStatusLLVMFull;
6299 return;
6300 }
6297 LLVMTypeRef usize_llvm_type = get_llvm_type(g, usize_type);
6298 ZigLLVMDIType *usize_llvm_di_type = get_llvm_di_type(g, usize_type);
6299 ZigLLVMDIScope *compile_unit_scope = ZigLLVMCompileUnitToScope(g->compile_unit);
6300 ZigLLVMDIFile *di_file = nullptr;
6301 unsigned line = 0;
63016302
6303 if (type->data.structure.resolve_status < ResolveStatusLLVMFwdDecl) {
63026304 type->llvm_type = LLVMStructCreateNamed(LLVMGetGlobalContext(), buf_ptr(&type->name));
63036305
63046306 type->llvm_di_type = ZigLLVMCreateReplaceableCompositeType(g->dbuilder,
......@@ -6551,6 +6553,12 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) {
65516553 assert(enum_type->data.enumeration.complete);
65526554 if (enum_type->llvm_di_type != nullptr) return;
65536555
6556 if (!type_has_bits(enum_type)) {
6557 enum_type->llvm_type = g->builtin_types.entry_void->llvm_type;
6558 enum_type->llvm_di_type = g->builtin_types.entry_void->llvm_di_type;
6559 return;
6560 }
6561
65546562 uint32_t field_count = enum_type->data.enumeration.src_field_count;
65556563
65566564 assert(enum_type->data.enumeration.fields);
......@@ -6569,6 +6577,7 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) {
65696577 }
65706578
65716579 ZigType *tag_int_type = enum_type->data.enumeration.tag_int_type;
6580 enum_type->llvm_type = get_llvm_type(g, tag_int_type);
65726581
65736582 // create debug type for tag
65746583 AstNode *decl_node = enum_type->data.enumeration.decl_node;
......@@ -6583,7 +6592,6 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) {
65836592 get_llvm_di_type(g, tag_int_type), "");
65846593
65856594 enum_type->llvm_di_type = tag_di_type;
6586 enum_type->llvm_type = get_llvm_type(g, tag_int_type);
65876595}
65886596
65896597static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveStatus wanted_resolve_status) {
......@@ -6764,6 +6772,7 @@ static void resolve_llvm_types_pointer(CodeGen *g, ZigType *type) {
67646772 uint64_t debug_align_in_bits = 8*type->abi_align;
67656773 type->llvm_di_type = ZigLLVMCreateDebugPointerType(g->dbuilder, elem_type->llvm_di_type,
67666774 debug_size_in_bits, debug_align_in_bits, buf_ptr(&type->name));
6775 assertNoError(type_resolve(g, elem_type, ResolveStatusLLVMFull));
67676776 } else {
67686777 ZigType *host_int_type = get_int_type(g, false, type->data.pointer.host_int_bytes * 8);
67696778 LLVMTypeRef host_int_llvm_type = get_llvm_type(g, host_int_type);
......@@ -6939,6 +6948,12 @@ static void resolve_llvm_types_error_union(CodeGen *g, ZigType *type) {
69396948static void resolve_llvm_types_array(CodeGen *g, ZigType *type) {
69406949 if (type->llvm_di_type != nullptr) return;
69416950
6951 if (!type_has_bits(type)) {
6952 type->llvm_type = g->builtin_types.entry_void->llvm_type;
6953 type->llvm_di_type = g->builtin_types.entry_void->llvm_di_type;
6954 return;
6955 }
6956
69426957 ZigType *elem_type = type->data.array.child_type;
69436958
69446959 // TODO https://github.com/ziglang/zig/issues/1424
......@@ -7014,7 +7029,7 @@ static void resolve_llvm_types_fn(CodeGen *g, ZigType *fn_type) {
70147029 gen_param_info->src_index = i;
70157030 gen_param_info->gen_index = SIZE_MAX;
70167031
7017 if (!type_has_bits(type_entry))
7032 if (is_c_abi || !type_has_bits(type_entry))
70187033 continue;
70197034
70207035 ZigType *gen_type;
src/codegen.cpp+7-4
......@@ -3566,7 +3566,9 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI
35663566 return LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 1, "");
35673567 } else if (array_type->id == ZigTypeIdStruct) {
35683568 assert(array_type->data.structure.is_slice);
3569 if (!type_has_bits(instruction->base.value.type)) {
3569
3570 ZigType *ptr_type = instruction->base.value.type;
3571 if (!type_has_bits(ptr_type)) {
35703572 if (safety_check_on) {
35713573 assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMIntegerTypeKind);
35723574 add_bounds_check(g, subscript_value, LLVMIntEQ, nullptr, LLVMIntULT, array_ptr);
......@@ -5695,6 +5697,7 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) {
56955697 IrInstruction *instruction = current_block->instruction_list.at(instr_i);
56965698 if (instruction->ref_count == 0 && !ir_has_side_effects(instruction))
56975699 continue;
5700
56985701 instruction->llvm_value = ir_render_instruction(g, executable, instruction);
56995702 }
57005703 current_block->llvm_exit_block = LLVMGetInsertBlock(g->builder);
......@@ -6855,9 +6858,9 @@ static void do_code_gen(CodeGen *g) {
68556858 }
68566859 if (var->decl_node) {
68576860 var->di_loc_var = ZigLLVMCreateParameterVariable(g->dbuilder, get_di_scope(g, var->parent_scope),
6858 buf_ptr(&var->name), import->data.structure.root_struct->di_file,
6859 (unsigned)(var->decl_node->line + 1),
6860 get_llvm_di_type(g, gen_type), !g->strip_debug_symbols, 0, (unsigned)(gen_info->gen_index));
6861 buf_ptr(&var->name), import->data.structure.root_struct->di_file,
6862 (unsigned)(var->decl_node->line + 1),
6863 get_llvm_di_type(g, gen_type), !g->strip_debug_symbols, 0, (unsigned)(gen_info->gen_index+1));
68616864 }
68626865
68636866 }
src/zig_llvm.cpp+1
......@@ -548,6 +548,7 @@ ZigLLVMDILocalVariable *ZigLLVMCreateParameterVariable(ZigLLVMDIBuilder *dbuilde
548548 ZigLLVMDIType *type, bool always_preserve, unsigned flags, unsigned arg_no)
549549{
550550 assert(flags == 0);
551 assert(arg_no != 0);
551552 DILocalVariable *result = reinterpret_cast<DIBuilder*>(dbuilder)->createParameterVariable(
552553 reinterpret_cast<DIScope*>(scope),
553554 name,