@@ -1917,6 +1917,7 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime(
1917
1917
const ty_pl = sema.air_instructions.items(.data)[i].ty_pl;
1918
1918
const val = sema.air_values.items[ty_pl.payload];
1919
1919
if (val.tag() == .runtime_value) make_runtime.* = true;
1920
+ if (val.isPtrToThreadLocal(sema.mod)) make_runtime.* = true;
1920
1921
return val;
1921
1922
},
1922
1923
.const_ty => {
@@ -32086,15 +32087,36 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type {
32086
32087
const ptr_info = ptr_ty.ptrInfo().data;
32087
32088
const elem_ty = ptr_ty.elemType2();
32088
32089
const allow_zero = ptr_info.@"allowzero" and (offset orelse 0) == 0;
32090
+ const target = sema.mod.getTarget();
32091
+ const parent_ty = ptr_ty.childType();
32092
+
32093
+ const vector_info: struct {
32094
+ host_size: u16,
32095
+ bit_offset: u16,
32096
+ alignment: u32,
32097
+ } = if (parent_ty.tag() == .vector) blk: {
32098
+ const elem_bits = elem_ty.bitSize(target);
32099
+ const is_packed = elem_bits != 0 and (elem_bits & (elem_bits - 1)) != 0;
32100
+ // TODO: runtime-known index
32101
+ assert(!is_packed or offset != null);
32102
+ const is_packed_with_offset = is_packed and offset != null and offset.? != 0;
32103
+ const target_offset = if (is_packed_with_offset) (if (target.cpu.arch.endian() == .Big) (parent_ty.vectorLen() - 1 - offset.?) else offset.?) else 0;
32104
+ break :blk .{
32105
+ .host_size = if (is_packed_with_offset) @intCast(u16, parent_ty.abiSize(target)) else 0,
32106
+ .bit_offset = if (is_packed_with_offset) @intCast(u16, elem_bits * target_offset) else 0,
32107
+ .alignment = if (is_packed_with_offset) @intCast(u16, parent_ty.abiAlignment(target)) else 0,
32108
+ };
32109
+ } else .{ .host_size = 0, .bit_offset = 0, .alignment = 0 };
32110
+
32089
32111
const alignment: u32 = a: {
32090
32112
// Calculate the new pointer alignment.
32091
32113
if (ptr_info.@"align" == 0) {
32114
+ if (vector_info.alignment != 0) break :a vector_info.alignment;
32092
32115
// ABI-aligned pointer. Any pointer arithmetic maintains the same ABI-alignedness.
32093
32116
break :a 0;
32094
32117
}
32095
32118
// If the addend is not a comptime-known value we can still count on
32096
32119
// it being a multiple of the type size.
32097
- const target = sema.mod.getTarget();
32098
32120
const elem_size = elem_ty.abiSize(target);
32099
32121
const addend = if (offset) |off| elem_size * off else elem_size;
32100
32122
@@ -32111,5 +32133,7 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type {
32111
32133
.@"allowzero" = allow_zero,
32112
32134
.@"volatile" = ptr_info.@"volatile",
32113
32135
.@"align" = alignment,
32136
+ .host_size = vector_info.host_size,
32137
+ .bit_offset = vector_info.bit_offset,
32114
32138
});
32115
32139
}
0 commit comments