| ... | @@ -603,16 +603,30 @@ static LLVMValueRef get_floor_ceil_fn(CodeGen *g, TypeTableEntry *type_entry, Zi | ... | @@ -603,16 +603,30 @@ static LLVMValueRef get_floor_ceil_fn(CodeGen *g, TypeTableEntry *type_entry, Zi |
| 603 | return fn_val; | 603 | return fn_val; |
| 604 | } | 604 | } |
| 605 | | 605 | |
| | 606 | static LLVMValueRef gen_load_untyped(CodeGen *g, LLVMValueRef ptr, uint32_t alignment, bool is_volatile, |
| | 607 | const char *name) |
| | 608 | { |
| | 609 | LLVMValueRef result = LLVMBuildLoad(g->builder, ptr, name); |
| | 610 | if (is_volatile) LLVMSetVolatile(result, true); |
| | 611 | if (alignment == 0) { |
| | 612 | LLVMSetAlignment(result, LLVMABIAlignmentOfType(g->target_data_ref, LLVMGetElementType(LLVMTypeOf(ptr)))); |
| | 613 | } else { |
| | 614 | LLVMSetAlignment(result, alignment); |
| | 615 | } |
| | 616 | return result; |
| | 617 | } |
| | 618 | |
| | 619 | static LLVMValueRef gen_load(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *ptr_type, const char *name) { |
| | 620 | return gen_load_untyped(g, ptr, ptr_type->data.pointer.alignment, ptr_type->data.pointer.is_volatile, name); |
| | 621 | } |
| | 622 | |
| 606 | static LLVMValueRef get_handle_value(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *type, TypeTableEntry *ptr_type) { | 623 | static LLVMValueRef get_handle_value(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *type, TypeTableEntry *ptr_type) { |
| 607 | if (type_has_bits(type)) { | 624 | if (type_has_bits(type)) { |
| 608 | if (handle_is_ptr(type)) { | 625 | if (handle_is_ptr(type)) { |
| 609 | return ptr; | 626 | return ptr; |
| 610 | } else { | 627 | } else { |
| 611 | assert(ptr_type->id == TypeTableEntryIdPointer); | 628 | assert(ptr_type->id == TypeTableEntryIdPointer); |
| 612 | LLVMValueRef result = LLVMBuildLoad(g->builder, ptr, ""); | 629 | return gen_load(g, ptr, ptr_type, ""); |
| 613 | LLVMSetVolatile(result, ptr_type->data.pointer.is_volatile); | | |
| 614 | LLVMSetAlignment(result, ptr_type->data.pointer.alignment); | | |
| 615 | return result; | | |
| 616 | } | 630 | } |
| 617 | } else { | 631 | } else { |
| 618 | return nullptr; | 632 | return nullptr; |
| ... | @@ -727,8 +741,8 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) { | ... | @@ -727,8 +741,8 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) { |
| 727 | LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)ptr_index, ""); | 741 | LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)ptr_index, ""); |
| 728 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)len_index, ""); | 742 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)len_index, ""); |
| 729 | | 743 | |
| 730 | LLVMValueRef msg_ptr = LLVMBuildLoad(g->builder, ptr_ptr, ""); | 744 | LLVMValueRef msg_ptr = gen_load_untyped(g, ptr_ptr, 0, false, ""); |
| 731 | LLVMValueRef msg_len = LLVMBuildLoad(g->builder, len_ptr, ""); | 745 | LLVMValueRef msg_len = gen_load_untyped(g, len_ptr, 0, false, ""); |
| 732 | gen_panic_raw(g, msg_ptr, msg_len); | 746 | gen_panic_raw(g, msg_ptr, msg_len); |
| 733 | } | 747 | } |
| 734 | | 748 | |
| ... | @@ -828,10 +842,10 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) { | ... | @@ -828,10 +842,10 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) { |
| 828 | LLVMValueRef err_name_val = LLVMBuildInBoundsGEP(g->builder, g->err_name_table, err_table_indices, 2, ""); | 842 | LLVMValueRef err_name_val = LLVMBuildInBoundsGEP(g->builder, g->err_name_table, err_table_indices, 2, ""); |
| 829 | | 843 | |
| 830 | LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, err_name_val, slice_ptr_index, ""); | 844 | LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, err_name_val, slice_ptr_index, ""); |
| 831 | LLVMValueRef err_name_ptr = LLVMBuildLoad(g->builder, ptr_field_ptr, ""); | 845 | LLVMValueRef err_name_ptr = gen_load_untyped(g, ptr_field_ptr, 0, false, ""); |
| 832 | | 846 | |
| 833 | LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, err_name_val, slice_len_index, ""); | 847 | LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, err_name_val, slice_len_index, ""); |
| 834 | LLVMValueRef err_name_len = LLVMBuildLoad(g->builder, len_field_ptr, ""); | 848 | LLVMValueRef err_name_len = gen_load_untyped(g, len_field_ptr, 0, false, ""); |
| 835 | | 849 | |
| 836 | LLVMValueRef params[] = { | 850 | LLVMValueRef params[] = { |
| 837 | offset_buf_ptr, // dest pointer | 851 | offset_buf_ptr, // dest pointer |
| ... | @@ -1081,7 +1095,7 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry | ... | @@ -1081,7 +1095,7 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry |
| 1081 | return nullptr; | 1095 | return nullptr; |
| 1082 | } | 1096 | } |
| 1083 | | 1097 | |
| 1084 | LLVMValueRef containing_int = LLVMBuildLoad(g->builder, ptr, ""); | 1098 | LLVMValueRef containing_int = gen_load(g, ptr, ptr_type, ""); |
| 1085 | | 1099 | |
| 1086 | uint32_t bit_offset = ptr_type->data.pointer.bit_offset; | 1100 | uint32_t bit_offset = ptr_type->data.pointer.bit_offset; |
| 1087 | uint32_t host_bit_count = LLVMGetIntTypeWidth(LLVMTypeOf(containing_int)); | 1101 | uint32_t host_bit_count = LLVMGetIntTypeWidth(LLVMTypeOf(containing_int)); |
| ... | @@ -1144,7 +1158,7 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrIns | ... | @@ -1144,7 +1158,7 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrIns |
| 1144 | gen_assign_raw(g, g->cur_ret_ptr, get_pointer_to_type(g, return_type, false), value); | 1158 | gen_assign_raw(g, g->cur_ret_ptr, get_pointer_to_type(g, return_type, false), value); |
| 1145 | LLVMBuildRetVoid(g->builder); | 1159 | LLVMBuildRetVoid(g->builder); |
| 1146 | } else { | 1160 | } else { |
| 1147 | LLVMValueRef by_val_value = LLVMBuildLoad(g->builder, value, ""); | 1161 | LLVMValueRef by_val_value = gen_load_untyped(g, value, 0, false, ""); |
| 1148 | LLVMBuildRet(g->builder, by_val_value); | 1162 | LLVMBuildRet(g->builder, by_val_value); |
| 1149 | } | 1163 | } |
| 1150 | } else { | 1164 | } else { |
| ... | @@ -1654,7 +1668,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable, | ... | @@ -1654,7 +1668,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable, |
| 1654 | size_t wanted_len_index = wanted_type->data.structure.fields[slice_len_index].gen_index; | 1668 | size_t wanted_len_index = wanted_type->data.structure.fields[slice_len_index].gen_index; |
| 1655 | | 1669 | |
| 1656 | LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_ptr_index, ""); | 1670 | LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_ptr_index, ""); |
| 1657 | LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, ""); | 1671 | LLVMValueRef src_ptr = gen_load_untyped(g, src_ptr_ptr, 0, false, ""); |
| 1658 | LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr, | 1672 | LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr, |
| 1659 | wanted_type->data.structure.fields[0].type_entry->type_ref, ""); | 1673 | wanted_type->data.structure.fields[0].type_entry->type_ref, ""); |
| 1660 | LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, | 1674 | LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, |
| ... | @@ -1662,7 +1676,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable, | ... | @@ -1662,7 +1676,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable, |
| 1662 | LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr); | 1676 | LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr); |
| 1663 | | 1677 | |
| 1664 | LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_len_index, ""); | 1678 | LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_len_index, ""); |
| 1665 | LLVMValueRef src_len = LLVMBuildLoad(g->builder, src_len_ptr, ""); | 1679 | LLVMValueRef src_len = gen_load_untyped(g, src_len_ptr, 0, false, ""); |
| 1666 | uint64_t src_size = type_size(g, actual_child_type); | 1680 | uint64_t src_size = type_size(g, actual_child_type); |
| 1667 | uint64_t dest_size = type_size(g, wanted_child_type); | 1681 | uint64_t dest_size = type_size(g, wanted_child_type); |
| 1668 | | 1682 | |
| ... | @@ -2036,8 +2050,7 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, IrI | ... | @@ -2036,8 +2050,7 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, IrI |
| 2036 | return get_handle_value(g, ptr, child_type, ptr_type); | 2050 | return get_handle_value(g, ptr, child_type, ptr_type); |
| 2037 | | 2051 | |
| 2038 | assert(!handle_is_ptr(child_type)); | 2052 | assert(!handle_is_ptr(child_type)); |
| 2039 | LLVMValueRef containing_int = LLVMBuildLoad(g->builder, ptr, ""); | 2053 | LLVMValueRef containing_int = gen_load(g, ptr, ptr_type, ""); |
| 2040 | LLVMSetVolatile(containing_int, ptr_type->data.pointer.is_volatile); | | |
| 2041 | | 2054 | |
| 2042 | uint32_t bit_offset = ptr_type->data.pointer.bit_offset; | 2055 | uint32_t bit_offset = ptr_type->data.pointer.bit_offset; |
| 2043 | uint32_t host_bit_count = LLVMGetIntTypeWidth(LLVMTypeOf(containing_int)); | 2056 | uint32_t host_bit_count = LLVMGetIntTypeWidth(LLVMTypeOf(containing_int)); |
| ... | @@ -2133,14 +2146,14 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI | ... | @@ -2133,14 +2146,14 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI |
| 2133 | size_t len_index = array_type->data.structure.fields[1].gen_index; | 2146 | size_t len_index = array_type->data.structure.fields[1].gen_index; |
| 2134 | assert(len_index != SIZE_MAX); | 2147 | assert(len_index != SIZE_MAX); |
| 2135 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, ""); | 2148 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, ""); |
| 2136 | LLVMValueRef len = LLVMBuildLoad(g->builder, len_ptr, ""); | 2149 | LLVMValueRef len = gen_load_untyped(g, len_ptr, 0, false, ""); |
| 2137 | add_bounds_check(g, subscript_value, LLVMIntEQ, nullptr, LLVMIntULT, len); | 2150 | add_bounds_check(g, subscript_value, LLVMIntEQ, nullptr, LLVMIntULT, len); |
| 2138 | } | 2151 | } |
| 2139 | | 2152 | |
| 2140 | size_t ptr_index = array_type->data.structure.fields[0].gen_index; | 2153 | size_t ptr_index = array_type->data.structure.fields[0].gen_index; |
| 2141 | assert(ptr_index != SIZE_MAX); | 2154 | assert(ptr_index != SIZE_MAX); |
| 2142 | LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, ""); | 2155 | LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, ""); |
| 2143 | LLVMValueRef ptr = LLVMBuildLoad(g->builder, ptr_ptr, ""); | 2156 | LLVMValueRef ptr = gen_load_untyped(g, ptr_ptr, 0, false, ""); |
| 2144 | return LLVMBuildInBoundsGEP(g->builder, ptr, &subscript_value, 1, ""); | 2157 | return LLVMBuildInBoundsGEP(g->builder, ptr, &subscript_value, 1, ""); |
| 2145 | } else { | 2158 | } else { |
| 2146 | zig_unreachable(); | 2159 | zig_unreachable(); |
| ... | @@ -2388,7 +2401,7 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLV | ... | @@ -2388,7 +2401,7 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLV |
| 2388 | return LLVMBuildICmp(g->builder, LLVMIntNE, maybe_handle, LLVMConstNull(maybe_type->type_ref), ""); | 2401 | return LLVMBuildICmp(g->builder, LLVMIntNE, maybe_handle, LLVMConstNull(maybe_type->type_ref), ""); |
| 2389 | } else { | 2402 | } else { |
| 2390 | LLVMValueRef maybe_field_ptr = LLVMBuildStructGEP(g->builder, maybe_handle, maybe_null_index, ""); | 2403 | LLVMValueRef maybe_field_ptr = LLVMBuildStructGEP(g->builder, maybe_handle, maybe_null_index, ""); |
| 2391 | return LLVMBuildLoad(g->builder, maybe_field_ptr, ""); | 2404 | return gen_load_untyped(g, maybe_field_ptr, 0, false, ""); |
| 2392 | } | 2405 | } |
| 2393 | } | 2406 | } |
| 2394 | } | 2407 | } |
| ... | @@ -2607,12 +2620,6 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executa | ... | @@ -2607,12 +2620,6 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executa |
| 2607 | } | 2620 | } |
| 2608 | } | 2621 | } |
| 2609 | | 2622 | |
| 2610 | static LLVMValueRef get_default_aligned_load(CodeGen *g, LLVMValueRef ptr) { | | |
| 2611 | LLVMValueRef result = LLVMBuildLoad(g->builder, ptr, ""); | | |
| 2612 | LLVMSetAlignment(result, LLVMABIAlignmentOfType(g->target_data_ref, LLVMGetElementType(LLVMTypeOf(ptr)))); | | |
| 2613 | return result; | | |
| 2614 | } | | |
| 2615 | | | |
| 2616 | static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, IrInstructionAlignCast *instruction) { | 2623 | static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, IrInstructionAlignCast *instruction) { |
| 2617 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); | 2624 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 2618 | assert(target_val); | 2625 | assert(target_val); |
| ... | @@ -2648,7 +2655,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I | ... | @@ -2648,7 +2655,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I |
| 2648 | | 2655 | |
| 2649 | size_t ptr_index = target_type->data.structure.fields[slice_ptr_index].gen_index; | 2656 | size_t ptr_index = target_type->data.structure.fields[slice_ptr_index].gen_index; |
| 2650 | LLVMValueRef ptr_val_ptr = LLVMBuildStructGEP(g->builder, target_val, (unsigned)ptr_index, ""); | 2657 | LLVMValueRef ptr_val_ptr = LLVMBuildStructGEP(g->builder, target_val, (unsigned)ptr_index, ""); |
| 2651 | ptr_val = get_default_aligned_load(g, ptr_val_ptr); | 2658 | ptr_val = gen_load_untyped(g, ptr_val_ptr, 0, false, ""); |
| 2652 | } else { | 2659 | } else { |
| 2653 | zig_unreachable(); | 2660 | zig_unreachable(); |
| 2654 | } | 2661 | } |
| ... | @@ -2858,7 +2865,7 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst | ... | @@ -2858,7 +2865,7 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst |
| 2858 | LLVMValueRef prev_end = nullptr; | 2865 | LLVMValueRef prev_end = nullptr; |
| 2859 | if (!instruction->end || want_debug_safety) { | 2866 | if (!instruction->end || want_debug_safety) { |
| 2860 | LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, ""); | 2867 | LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, ""); |
| 2861 | prev_end = LLVMBuildLoad(g->builder, src_len_ptr, ""); | 2868 | prev_end = gen_load_untyped(g, src_len_ptr, 0, false, ""); |
| 2862 | } | 2869 | } |
| 2863 | | 2870 | |
| 2864 | LLVMValueRef start_val = ir_llvm_value(g, instruction->start); | 2871 | LLVMValueRef start_val = ir_llvm_value(g, instruction->start); |
| ... | @@ -2878,7 +2885,7 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst | ... | @@ -2878,7 +2885,7 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst |
| 2878 | } | 2885 | } |
| 2879 | | 2886 | |
| 2880 | LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, ""); | 2887 | LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, ""); |
| 2881 | LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, ""); | 2888 | LLVMValueRef src_ptr = gen_load_untyped(g, src_ptr_ptr, 0, false, ""); |
| 2882 | LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)ptr_index, ""); | 2889 | LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)ptr_index, ""); |
| 2883 | LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, (unsigned)len_index, ""); | 2890 | LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, (unsigned)len_index, ""); |
| 2884 | LLVMBuildStore(g->builder, slice_start_ptr, ptr_field_ptr); | 2891 | LLVMBuildStore(g->builder, slice_start_ptr, ptr_field_ptr); |
| ... | @@ -3023,7 +3030,7 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrI | ... | @@ -3023,7 +3030,7 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrI |
| 3023 | LLVMValueRef err_val; | 3030 | LLVMValueRef err_val; |
| 3024 | if (type_has_bits(child_type)) { | 3031 | if (type_has_bits(child_type)) { |
| 3025 | LLVMValueRef err_val_ptr = LLVMBuildStructGEP(g->builder, err_union_handle, err_union_err_index, ""); | 3032 | LLVMValueRef err_val_ptr = LLVMBuildStructGEP(g->builder, err_union_handle, err_union_err_index, ""); |
| 3026 | err_val = LLVMBuildLoad(g->builder, err_val_ptr, ""); | 3033 | err_val = gen_load_untyped(g, err_val_ptr, 0, false, ""); |
| 3027 | } else { | 3034 | } else { |
| 3028 | err_val = err_union_handle; | 3035 | err_val = err_union_handle; |
| 3029 | } | 3036 | } |
| ... | @@ -3042,7 +3049,7 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executab | ... | @@ -3042,7 +3049,7 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executab |
| 3042 | | 3049 | |
| 3043 | if (type_has_bits(child_type)) { | 3050 | if (type_has_bits(child_type)) { |
| 3044 | LLVMValueRef err_val_ptr = LLVMBuildStructGEP(g->builder, err_union_handle, err_union_err_index, ""); | 3051 | LLVMValueRef err_val_ptr = LLVMBuildStructGEP(g->builder, err_union_handle, err_union_err_index, ""); |
| 3045 | return LLVMBuildLoad(g->builder, err_val_ptr, ""); | 3052 | return gen_load_untyped(g, err_val_ptr, 0, false, ""); |
| 3046 | } else { | 3053 | } else { |
| 3047 | return err_union_handle; | 3054 | return err_union_handle; |
| 3048 | } | 3055 | } |
| ... | @@ -3060,7 +3067,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *execu | ... | @@ -3060,7 +3067,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *execu |
| 3060 | LLVMValueRef err_val; | 3067 | LLVMValueRef err_val; |
| 3061 | if (type_has_bits(child_type)) { | 3068 | if (type_has_bits(child_type)) { |
| 3062 | LLVMValueRef err_val_ptr = LLVMBuildStructGEP(g->builder, err_union_handle, err_union_err_index, ""); | 3069 | LLVMValueRef err_val_ptr = LLVMBuildStructGEP(g->builder, err_union_handle, err_union_err_index, ""); |
| 3063 | err_val = LLVMBuildLoad(g->builder, err_val_ptr, ""); | 3070 | err_val = gen_load_untyped(g, err_val_ptr, 0, false, ""); |
| 3064 | } else { | 3071 | } else { |
| 3065 | err_val = err_union_handle; | 3072 | err_val = err_union_handle; |
| 3066 | } | 3073 | } |
| ... | @@ -3922,6 +3929,7 @@ static void generate_error_name_table(CodeGen *g) { | ... | @@ -3922,6 +3929,7 @@ static void generate_error_name_table(CodeGen *g) { |
| 3922 | LLVMSetLinkage(str_global, LLVMPrivateLinkage); | 3929 | LLVMSetLinkage(str_global, LLVMPrivateLinkage); |
| 3923 | LLVMSetGlobalConstant(str_global, true); | 3930 | LLVMSetGlobalConstant(str_global, true); |
| 3924 | LLVMSetUnnamedAddr(str_global, true); | 3931 | LLVMSetUnnamedAddr(str_global, true); |
| | 3932 | LLVMSetAlignment(str_global, LLVMABIAlignmentOfType(g->target_data_ref, LLVMTypeOf(str_init))); |
| 3925 | | 3933 | |
| 3926 | LLVMValueRef fields[] = { | 3934 | LLVMValueRef fields[] = { |
| 3927 | LLVMConstBitCast(str_global, u8_ptr_type->type_ref), | 3935 | LLVMConstBitCast(str_global, u8_ptr_type->type_ref), |
| ... | @@ -3938,6 +3946,7 @@ static void generate_error_name_table(CodeGen *g) { | ... | @@ -3938,6 +3946,7 @@ static void generate_error_name_table(CodeGen *g) { |
| 3938 | LLVMSetLinkage(g->err_name_table, LLVMPrivateLinkage); | 3946 | LLVMSetLinkage(g->err_name_table, LLVMPrivateLinkage); |
| 3939 | LLVMSetGlobalConstant(g->err_name_table, true); | 3947 | LLVMSetGlobalConstant(g->err_name_table, true); |
| 3940 | LLVMSetUnnamedAddr(g->err_name_table, true); | 3948 | LLVMSetUnnamedAddr(g->err_name_table, true); |
| | 3949 | LLVMSetAlignment(g->err_name_table, LLVMABIAlignmentOfType(g->target_data_ref, LLVMTypeOf(err_name_table_init))); |
| 3941 | } | 3950 | } |
| 3942 | | 3951 | |
| 3943 | static void generate_enum_name_tables(CodeGen *g) { | 3952 | static void generate_enum_name_tables(CodeGen *g) { |
| ... | @@ -3960,6 +3969,7 @@ static void generate_enum_name_tables(CodeGen *g) { | ... | @@ -3960,6 +3969,7 @@ static void generate_enum_name_tables(CodeGen *g) { |
| 3960 | LLVMSetLinkage(str_global, LLVMPrivateLinkage); | 3969 | LLVMSetLinkage(str_global, LLVMPrivateLinkage); |
| 3961 | LLVMSetGlobalConstant(str_global, true); | 3970 | LLVMSetGlobalConstant(str_global, true); |
| 3962 | LLVMSetUnnamedAddr(str_global, true); | 3971 | LLVMSetUnnamedAddr(str_global, true); |
| | 3972 | LLVMSetAlignment(str_global, LLVMABIAlignmentOfType(g->target_data_ref, LLVMTypeOf(str_init))); |
| 3963 | | 3973 | |
| 3964 | LLVMValueRef fields[] = { | 3974 | LLVMValueRef fields[] = { |
| 3965 | LLVMConstBitCast(str_global, u8_ptr_type->type_ref), | 3975 | LLVMConstBitCast(str_global, u8_ptr_type->type_ref), |
| ... | @@ -3976,6 +3986,7 @@ static void generate_enum_name_tables(CodeGen *g) { | ... | @@ -3976,6 +3986,7 @@ static void generate_enum_name_tables(CodeGen *g) { |
| 3976 | LLVMSetLinkage(name_table, LLVMPrivateLinkage); | 3986 | LLVMSetLinkage(name_table, LLVMPrivateLinkage); |
| 3977 | LLVMSetGlobalConstant(name_table, true); | 3987 | LLVMSetGlobalConstant(name_table, true); |
| 3978 | LLVMSetUnnamedAddr(name_table, true); | 3988 | LLVMSetUnnamedAddr(name_table, true); |
| | 3989 | LLVMSetAlignment(name_table, LLVMABIAlignmentOfType(g->target_data_ref, LLVMTypeOf(name_table_init))); |
| 3979 | enum_tag_type->data.enum_tag.name_table = name_table; | 3990 | enum_tag_type->data.enum_tag.name_table = name_table; |
| 3980 | } | 3991 | } |
| 3981 | } | 3992 | } |