authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-03-14 23:49:45-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-03-15 01:04:21-04:00
logd70955b0df92fdd0fdf3680f7f297a4cc676ee5a
tree4931a3dcef12430f8ef7788db233e74559baea46
parentba9d93dc9fd341f4dc08082f894fcbc1060cdcad

x86_64: turn packed struct crashes into compile errors


1 files changed, 9 insertions(+), 0 deletions(-)

src/arch/x86_64/CodeGen.zig+9
...@@ -3053,6 +3053,9 @@ fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, inde...@@ -3053,6 +3053,9 @@ fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, inde
3053 const mcv = try self.resolveInst(operand);3053 const mcv = try self.resolveInst(operand);
3054 const ptr_ty = self.air.typeOf(operand);3054 const ptr_ty = self.air.typeOf(operand);
3055 const struct_ty = ptr_ty.childType();3055 const struct_ty = ptr_ty.childType();
3056 if (struct_ty.zigTypeTag() == .Struct and struct_ty.containerLayout() == .Packed) {
3057 return self.fail("TODO structFieldPtr implement packed structs", .{});
3058 }
3056 const struct_field_offset = @intCast(u32, struct_ty.structFieldOffset(index, self.target.*));3059 const struct_field_offset = @intCast(u32, struct_ty.structFieldOffset(index, self.target.*));
30573060
3058 const dst_mcv: MCValue = result: {3061 const dst_mcv: MCValue = result: {
...@@ -3116,6 +3119,9 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -3116,6 +3119,9 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
31163119
3117 const mcv = try self.resolveInst(operand);3120 const mcv = try self.resolveInst(operand);
3118 const struct_ty = self.air.typeOf(operand);3121 const struct_ty = self.air.typeOf(operand);
3122 if (struct_ty.zigTypeTag() == .Struct and struct_ty.containerLayout() == .Packed) {
3123 return self.fail("TODO airStructFieldVal implement packed structs", .{});
3124 }
3119 const struct_field_offset = struct_ty.structFieldOffset(index, self.target.*);3125 const struct_field_offset = struct_ty.structFieldOffset(index, self.target.*);
3120 const struct_field_ty = struct_ty.structFieldType(index);3126 const struct_field_ty = struct_ty.structFieldType(index);
31213127
...@@ -6242,6 +6248,9 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {...@@ -6242,6 +6248,9 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
6242 if (self.liveness.isUnused(inst)) break :res MCValue.dead;6248 if (self.liveness.isUnused(inst)) break :res MCValue.dead;
6243 switch (result_ty.zigTypeTag()) {6249 switch (result_ty.zigTypeTag()) {
6244 .Struct => {6250 .Struct => {
6251 if (result_ty.containerLayout() == .Packed) {
6252 return self.fail("TODO airAggregateInit implement packed structs", .{});
6253 }
6245 const stack_offset = @intCast(i32, try self.allocMem(inst, abi_size, abi_align));6254 const stack_offset = @intCast(i32, try self.allocMem(inst, abi_size, abi_align));
6246 for (elements, 0..) |elem, elem_i| {6255 for (elements, 0..) |elem, elem_i| {
6247 if (result_ty.structFieldValueComptime(elem_i) != null) continue; // comptime elem6256 if (result_ty.structFieldValueComptime(elem_i) != null) continue; // comptime elem