| ... | @@ -6252,53 +6252,55 @@ static void resolve_llvm_types_slice(CodeGen *g, ZigType *type, ResolveStatus wa | ... | @@ -6252,53 +6252,55 @@ static void resolve_llvm_types_slice(CodeGen *g, ZigType *type, ResolveStatus wa |
| 6252 | ZigType *ptr_type = type->data.structure.fields[slice_ptr_index].type_entry; | 6252 | ZigType *ptr_type = type->data.structure.fields[slice_ptr_index].type_entry; |
| 6253 | ZigType *child_type = ptr_type->data.pointer.child_type; | 6253 | ZigType *child_type = ptr_type->data.pointer.child_type; |
| 6254 | ZigType *usize_type = g->builtin_types.entry_usize; | 6254 | 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; | | |
| 6260 | | 6255 | |
| 6261 | if (type->data.structure.resolve_status < ResolveStatusLLVMFwdDecl) { | 6256 | bool done = false; |
| 6262 | bool done = false; | 6257 | if (ptr_type->data.pointer.is_const || ptr_type->data.pointer.is_volatile || |
| 6263 | 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) |
| 6264 | 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) |
| 6265 | { | 6278 | { |
| 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, |
| 6267 | PtrLenUnknown, 0, 0, 0, false); | 6284 | PtrLenUnknown, 0, 0, 0, false); |
| 6268 | ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type); | 6285 | ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type); |
| 6269 | | 6286 | |
| 6270 | type->llvm_type = get_llvm_type(g, peer_slice_type); | 6287 | assertNoError(type_resolve(g, peer_slice_type, wanted_resolve_status)); |
| 6271 | type->llvm_di_type = get_llvm_di_type(g, peer_slice_type); | 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; |
| 6272 | done = true; | 6291 | done = true; |
| 6273 | } | 6292 | } |
| | 6293 | } |
| 6274 | | 6294 | |
| 6275 | // If the child type is []const T then we need to make sure the type ref | 6295 | if (done) return; |
| 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 | } | | |
| 6296 | | 6296 | |
| 6297 | if (done) { | 6297 | LLVMTypeRef usize_llvm_type = get_llvm_type(g, usize_type); |
| 6298 | type->data.structure.resolve_status = ResolveStatusLLVMFull; | 6298 | ZigLLVMDIType *usize_llvm_di_type = get_llvm_di_type(g, usize_type); |
| 6299 | return; | 6299 | ZigLLVMDIScope *compile_unit_scope = ZigLLVMCompileUnitToScope(g->compile_unit); |
| 6300 | } | 6300 | ZigLLVMDIFile *di_file = nullptr; |
| | 6301 | unsigned line = 0; |
| 6301 | | 6302 | |
| | 6303 | if (type->data.structure.resolve_status < ResolveStatusLLVMFwdDecl) { |
| 6302 | type->llvm_type = LLVMStructCreateNamed(LLVMGetGlobalContext(), buf_ptr(&type->name)); | 6304 | type->llvm_type = LLVMStructCreateNamed(LLVMGetGlobalContext(), buf_ptr(&type->name)); |
| 6303 | | 6305 | |
| 6304 | type->llvm_di_type = ZigLLVMCreateReplaceableCompositeType(g->dbuilder, | 6306 | type->llvm_di_type = ZigLLVMCreateReplaceableCompositeType(g->dbuilder, |
| ... | @@ -6551,6 +6553,12 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { | ... | @@ -6551,6 +6553,12 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { |
| 6551 | assert(enum_type->data.enumeration.complete); | 6553 | assert(enum_type->data.enumeration.complete); |
| 6552 | if (enum_type->llvm_di_type != nullptr) return; | 6554 | if (enum_type->llvm_di_type != nullptr) return; |
| 6553 | | 6555 | |
| | 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 | |
| 6554 | uint32_t field_count = enum_type->data.enumeration.src_field_count; | 6562 | uint32_t field_count = enum_type->data.enumeration.src_field_count; |
| 6555 | | 6563 | |
| 6556 | assert(enum_type->data.enumeration.fields); | 6564 | assert(enum_type->data.enumeration.fields); |
| ... | @@ -6569,6 +6577,7 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { | ... | @@ -6569,6 +6577,7 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { |
| 6569 | } | 6577 | } |
| 6570 | | 6578 | |
| 6571 | ZigType *tag_int_type = enum_type->data.enumeration.tag_int_type; | 6579 | ZigType *tag_int_type = enum_type->data.enumeration.tag_int_type; |
| | 6580 | enum_type->llvm_type = get_llvm_type(g, tag_int_type); |
| 6572 | | 6581 | |
| 6573 | // create debug type for tag | 6582 | // create debug type for tag |
| 6574 | AstNode *decl_node = enum_type->data.enumeration.decl_node; | 6583 | AstNode *decl_node = enum_type->data.enumeration.decl_node; |
| ... | @@ -6583,7 +6592,6 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { | ... | @@ -6583,7 +6592,6 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type) { |
| 6583 | get_llvm_di_type(g, tag_int_type), ""); | 6592 | get_llvm_di_type(g, tag_int_type), ""); |
| 6584 | | 6593 | |
| 6585 | enum_type->llvm_di_type = tag_di_type; | 6594 | enum_type->llvm_di_type = tag_di_type; |
| 6586 | enum_type->llvm_type = get_llvm_type(g, tag_int_type); | | |
| 6587 | } | 6595 | } |
| 6588 | | 6596 | |
| 6589 | static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveStatus wanted_resolve_status) { | 6597 | static 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) { | ... | @@ -6764,6 +6772,7 @@ static void resolve_llvm_types_pointer(CodeGen *g, ZigType *type) { |
| 6764 | uint64_t debug_align_in_bits = 8*type->abi_align; | 6772 | uint64_t debug_align_in_bits = 8*type->abi_align; |
| 6765 | type->llvm_di_type = ZigLLVMCreateDebugPointerType(g->dbuilder, elem_type->llvm_di_type, | 6773 | type->llvm_di_type = ZigLLVMCreateDebugPointerType(g->dbuilder, elem_type->llvm_di_type, |
| 6766 | debug_size_in_bits, debug_align_in_bits, buf_ptr(&type->name)); | 6774 | debug_size_in_bits, debug_align_in_bits, buf_ptr(&type->name)); |
| | 6775 | assertNoError(type_resolve(g, elem_type, ResolveStatusLLVMFull)); |
| 6767 | } else { | 6776 | } else { |
| 6768 | ZigType *host_int_type = get_int_type(g, false, type->data.pointer.host_int_bytes * 8); | 6777 | ZigType *host_int_type = get_int_type(g, false, type->data.pointer.host_int_bytes * 8); |
| 6769 | LLVMTypeRef host_int_llvm_type = get_llvm_type(g, host_int_type); | 6778 | 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) { | ... | @@ -6939,6 +6948,12 @@ static void resolve_llvm_types_error_union(CodeGen *g, ZigType *type) { |
| 6939 | static void resolve_llvm_types_array(CodeGen *g, ZigType *type) { | 6948 | static void resolve_llvm_types_array(CodeGen *g, ZigType *type) { |
| 6940 | if (type->llvm_di_type != nullptr) return; | 6949 | if (type->llvm_di_type != nullptr) return; |
| 6941 | | 6950 | |
| | 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 | |
| 6942 | ZigType *elem_type = type->data.array.child_type; | 6957 | ZigType *elem_type = type->data.array.child_type; |
| 6943 | | 6958 | |
| 6944 | // TODO https://github.com/ziglang/zig/issues/1424 | 6959 | // TODO https://github.com/ziglang/zig/issues/1424 |
| ... | @@ -7014,7 +7029,7 @@ static void resolve_llvm_types_fn(CodeGen *g, ZigType *fn_type) { | ... | @@ -7014,7 +7029,7 @@ static void resolve_llvm_types_fn(CodeGen *g, ZigType *fn_type) { |
| 7014 | gen_param_info->src_index = i; | 7029 | gen_param_info->src_index = i; |
| 7015 | gen_param_info->gen_index = SIZE_MAX; | 7030 | gen_param_info->gen_index = SIZE_MAX; |
| 7016 | | 7031 | |
| 7017 | if (!type_has_bits(type_entry)) | 7032 | if (is_c_abi || !type_has_bits(type_entry)) |
| 7018 | continue; | 7033 | continue; |
| 7019 | | 7034 | |
| 7020 | ZigType *gen_type; | 7035 | ZigType *gen_type; |