| ... | @@ -5513,6 +5513,15 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI | ... | @@ -5513,6 +5513,15 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI |
| 5513 | } | 5513 | } |
| 5514 | } | 5514 | } |
| 5515 | | 5515 | |
| | 5516 | if (!type_has_bits(g, array_type)) { |
| | 5517 | LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); |
| | 5518 | size_t gen_len_index = result_type->data.structure.fields[slice_len_index]->gen_index; |
| | 5519 | LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, ""); |
| | 5520 | LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, ""); |
| | 5521 | gen_store_untyped(g, len_value, len_field_ptr, 0, false); |
| | 5522 | return tmp_struct_ptr; |
| | 5523 | } |
| | 5524 | |
| 5516 | LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &start_val, 1, ""); | 5525 | LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &start_val, 1, ""); |
| 5517 | if (result_type->id == ZigTypeIdPointer) { | 5526 | if (result_type->id == ZigTypeIdPointer) { |
| 5518 | ir_assert(instruction->result_loc == nullptr, &instruction->base); | 5527 | ir_assert(instruction->result_loc == nullptr, &instruction->base); |
| ... | @@ -5521,18 +5530,11 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI | ... | @@ -5521,18 +5530,11 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI |
| 5521 | } | 5530 | } |
| 5522 | | 5531 | |
| 5523 | LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); | 5532 | LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); |
| 5524 | if (type_has_bits(g, array_type)) { | 5533 | size_t gen_ptr_index = result_type->data.structure.fields[slice_ptr_index]->gen_index; |
| 5525 | size_t gen_ptr_index = result_type->data.structure.fields[slice_ptr_index]->gen_index; | 5534 | LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_ptr_index, ""); |
| 5526 | LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_ptr_index, ""); | 5535 | gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false); |
| 5527 | gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false); | | |
| 5528 | } | | |
| 5529 | | | |
| 5530 | size_t gen_len_index = result_type->data.structure.fields[slice_len_index]->gen_index; | | |
| 5531 | LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, ""); | | |
| 5532 | LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, ""); | | |
| 5533 | gen_store_untyped(g, len_value, len_field_ptr, 0, false); | | |
| 5534 | | | |
| 5535 | return tmp_struct_ptr; | 5536 | return tmp_struct_ptr; |
| | 5537 | |
| 5536 | } else if (array_type->id == ZigTypeIdStruct) { | 5538 | } else if (array_type->id == ZigTypeIdStruct) { |
| 5537 | assert(array_type->data.structure.special == StructSpecialSlice); | 5539 | assert(array_type->data.structure.special == StructSpecialSlice); |
| 5538 | assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind); | 5540 | assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind); |