@@ -775,7 +775,8 @@ static LLVMValueRef gen_store_untyped(CodeGen *g, LLVMValueRef value, LLVMValueR
775
775
776
776
static LLVMValueRef gen_store (CodeGen *g, LLVMValueRef value, LLVMValueRef ptr, ZigType *ptr_type) {
777
777
assert (ptr_type->id == ZigTypeIdPointer);
778
- return gen_store_untyped (g, value, ptr, ptr_type->data .pointer .alignment , ptr_type->data .pointer .is_volatile );
778
+ uint32_t alignment = get_ptr_align (g, ptr_type);
779
+ return gen_store_untyped (g, value, ptr, alignment, ptr_type->data .pointer .is_volatile );
779
780
}
780
781
781
782
static LLVMValueRef gen_load_untyped (CodeGen *g, LLVMValueRef ptr, uint32_t alignment, bool is_volatile,
@@ -793,7 +794,8 @@ static LLVMValueRef gen_load_untyped(CodeGen *g, LLVMValueRef ptr, uint32_t alig
793
794
794
795
static LLVMValueRef gen_load (CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type, const char *name) {
795
796
assert (ptr_type->id == ZigTypeIdPointer);
796
- return gen_load_untyped (g, ptr, ptr_type->data .pointer .alignment , ptr_type->data .pointer .is_volatile , name);
797
+ uint32_t alignment = get_ptr_align (g, ptr_type);
798
+ return gen_load_untyped (g, ptr, alignment, ptr_type->data .pointer .is_volatile , name);
797
799
}
798
800
799
801
static LLVMValueRef get_handle_value (CodeGen *g, LLVMValueRef ptr, ZigType *type, ZigType *ptr_type) {
@@ -1795,7 +1797,7 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_ty
1795
1797
1796
1798
ZigType *usize = g->builtin_types .entry_usize ;
1797
1799
uint64_t size_bytes = LLVMStoreSizeOfType (g->target_data_ref , child_type->type_ref );
1798
- uint64_t align_bytes = ptr_type-> data . pointer . alignment ;
1800
+ uint64_t align_bytes = get_ptr_align (g, ptr_type) ;
1799
1801
assert (size_bytes > 0 );
1800
1802
assert (align_bytes > 0 );
1801
1803
@@ -4084,15 +4086,15 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
4084
4086
LLVMValueRef ptr_val;
4085
4087
4086
4088
if (target_type->id == ZigTypeIdPointer) {
4087
- align_bytes = target_type-> data . pointer . alignment ;
4089
+ align_bytes = get_ptr_align (g, target_type) ;
4088
4090
ptr_val = target_val;
4089
4091
} else if (target_type->id == ZigTypeIdFn) {
4090
4092
align_bytes = target_type->data .fn .fn_type_id .alignment ;
4091
4093
ptr_val = target_val;
4092
4094
} else if (target_type->id == ZigTypeIdOptional &&
4093
4095
target_type->data .maybe .child_type ->id == ZigTypeIdPointer)
4094
4096
{
4095
- align_bytes = target_type->data .maybe .child_type -> data . pointer . alignment ;
4097
+ align_bytes = get_ptr_align (g, target_type->data .maybe .child_type ) ;
4096
4098
ptr_val = target_val;
4097
4099
} else if (target_type->id == ZigTypeIdOptional &&
4098
4100
target_type->data .maybe .child_type ->id == ZigTypeIdFn)
@@ -4105,7 +4107,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
4105
4107
zig_panic (" TODO audit this function" );
4106
4108
} else if (target_type->id == ZigTypeIdStruct && target_type->data .structure .is_slice ) {
4107
4109
ZigType *slice_ptr_type = target_type->data .structure .fields [slice_ptr_index].type_entry ;
4108
- align_bytes = slice_ptr_type-> data . pointer . alignment ;
4110
+ align_bytes = get_ptr_align (g, slice_ptr_type) ;
4109
4111
4110
4112
size_t ptr_index = target_type->data .structure .fields [slice_ptr_index].gen_index ;
4111
4113
LLVMValueRef ptr_val_ptr = LLVMBuildStructGEP (g->builder , target_val, (unsigned )ptr_index, " " );
@@ -4260,7 +4262,8 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutable *executable, IrIns
4260
4262
LLVMValueRef is_volatile = ptr_type->data .pointer .is_volatile ?
4261
4263
LLVMConstAllOnes (LLVMInt1Type ()) : LLVMConstNull (LLVMInt1Type ());
4262
4264
4263
- LLVMValueRef align_val = LLVMConstInt (LLVMInt32Type (), ptr_type->data .pointer .alignment , false );
4265
+ uint32_t alignment = get_ptr_align (g, ptr_type);
4266
+ LLVMValueRef align_val = LLVMConstInt (LLVMInt32Type (), alignment, false );
4264
4267
4265
4268
LLVMValueRef params[] = {
4266
4269
dest_ptr_casted,
@@ -4293,7 +4296,7 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutable *executable, IrIns
4293
4296
LLVMValueRef is_volatile = (dest_ptr_type->data .pointer .is_volatile || src_ptr_type->data .pointer .is_volatile ) ?
4294
4297
LLVMConstAllOnes (LLVMInt1Type ()) : LLVMConstNull (LLVMInt1Type ());
4295
4298
4296
- uint32_t min_align_bytes = min (src_ptr_type-> data . pointer . alignment , dest_ptr_type-> data . pointer . alignment );
4299
+ uint32_t min_align_bytes = min (get_ptr_align (g, src_ptr_type), get_ptr_align (g, dest_ptr_type) );
4297
4300
LLVMValueRef align_val = LLVMConstInt (LLVMInt32Type (), min_align_bytes, false );
4298
4301
4299
4302
LLVMValueRef params[] = {
0 commit comments