authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-03-26 22:50:22-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-04-10 02:04:52-04:00
logf4a31bed98c5ee65c0e8494e0e0e15e418697cb8
treee9e38dbcef024e6a74115ddcde53c7b3570db379
parent1eb5d70d1261be143a5f3c1a73ea23335d8c0df6

x86_64: remove broken const value tracking


1 files changed, 27 insertions(+), 36 deletions(-)

src/arch/x86_64/CodeGen.zig+27-36
...@@ -83,7 +83,6 @@ end_di_column: u32,...@@ -83,7 +83,6 @@ end_di_column: u32,
83epilogue_relocs: std.ArrayListUnmanaged(Mir.Inst.Index) = .empty,83epilogue_relocs: std.ArrayListUnmanaged(Mir.Inst.Index) = .empty,
8484
85reused_operands: std.StaticBitSet(Liveness.bpi - 1) = undefined,85reused_operands: std.StaticBitSet(Liveness.bpi - 1) = undefined,
86const_tracking: ConstTrackingMap = .empty,
87inst_tracking: InstTrackingMap = .empty,86inst_tracking: InstTrackingMap = .empty,
8887
89// Key is the block instruction88// Key is the block instruction
...@@ -926,7 +925,6 @@ pub fn generate(...@@ -926,7 +925,6 @@ pub fn generate(
926 while (block_it.next()) |block| block.deinit(gpa);925 while (block_it.next()) |block| block.deinit(gpa);
927 function.blocks.deinit(gpa);926 function.blocks.deinit(gpa);
928 function.inst_tracking.deinit(gpa);927 function.inst_tracking.deinit(gpa);
929 function.const_tracking.deinit(gpa);
930 function.epilogue_relocs.deinit(gpa);928 function.epilogue_relocs.deinit(gpa);
931 function.mir_instructions.deinit(gpa);929 function.mir_instructions.deinit(gpa);
932 function.mir_extra.deinit(gpa);930 function.mir_extra.deinit(gpa);
...@@ -108991,40 +108989,35 @@ fn resolveInst(self: *CodeGen, ref: Air.Inst.Ref) InnerError!MCValue {...@@ -108991,40 +108989,35 @@ fn resolveInst(self: *CodeGen, ref: Air.Inst.Ref) InnerError!MCValue {
108991 // If the type has no codegen bits, no need to store it.108989 // If the type has no codegen bits, no need to store it.
108992 if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return .none;108990 if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return .none;
108993108991
108994 const mcv = if (ref.toIndex()) |inst| mcv: {108992 const mcv: MCValue = if (ref.toIndex()) |inst| mcv: {
108995 break :mcv self.inst_tracking.getPtr(inst).?.short;108993 break :mcv self.inst_tracking.getPtr(inst).?.short;
108996 } else mcv: {108994 } else mcv: {
108997 const ip_index = ref.toInterned().?;108995 const const_mcv = try self.genTypedValue(.fromInterned(ref.toInterned().?));
108998 const gop = try self.const_tracking.getOrPut(self.gpa, ip_index);108996 switch (const_mcv) {
108999 if (!gop.found_existing) gop.value_ptr.* = .init(init: {108997 .lea_tlv => |tlv_sym| switch (self.bin_file.tag) {
109000 const const_mcv = try self.genTypedValue(.fromInterned(ip_index));108998 .elf, .macho => {
109001 switch (const_mcv) {108999 if (self.mod.pic) {
109002 .lea_tlv => |tlv_sym| switch (self.bin_file.tag) {109000 try self.spillRegisters(&.{ .rdi, .rax });
109003 .elf, .macho => {109001 } else {
109004 if (self.mod.pic) {109002 try self.spillRegisters(&.{.rax});
109005 try self.spillRegisters(&.{ .rdi, .rax });109003 }
109006 } else {109004 const frame_index = try self.allocFrameIndex(.init(.{
109007 try self.spillRegisters(&.{.rax});109005 .size = 8,
109008 }109006 .alignment = .@"8",
109009 const frame_index = try self.allocFrameIndex(.init(.{109007 }));
109010 .size = 8,109008 try self.genSetMem(
109011 .alignment = .@"8",109009 .{ .frame = frame_index },
109012 }));109010 0,
109013 try self.genSetMem(109011 .usize,
109014 .{ .frame = frame_index },109012 .{ .lea_symbol = .{ .sym_index = tlv_sym } },
109015 0,109013 .{},
109016 .usize,109014 );
109017 .{ .lea_symbol = .{ .sym_index = tlv_sym } },109015 break :mcv .{ .load_frame = .{ .index = frame_index } };
109018 .{},
109019 );
109020 break :init .{ .load_frame = .{ .index = frame_index } };
109021 },
109022 else => break :init const_mcv,
109023 },109016 },
109024 else => break :init const_mcv,109017 else => break :mcv const_mcv,
109025 }109018 },
109026 });109019 else => break :mcv const_mcv,
109027 break :mcv gop.value_ptr.short;109020 }
109028 };109021 };
109029109022
109030 switch (mcv) {109023 switch (mcv) {
...@@ -115260,8 +115253,7 @@ fn tempFromOperand(cg: *CodeGen, op_ref: Air.Inst.Ref, op_dies: bool) InnerError...@@ -115260,8 +115253,7 @@ fn tempFromOperand(cg: *CodeGen, op_ref: Air.Inst.Ref, op_dies: bool) InnerError
115260115253
115261 if (op_ref.toIndex()) |op_inst| return .{ .index = op_inst };115254 if (op_ref.toIndex()) |op_inst| return .{ .index = op_inst };
115262 const val = op_ref.toInterned().?;115255 const val = op_ref.toInterned().?;
115263 const gop = try cg.const_tracking.getOrPut(cg.gpa, val);115256 return cg.tempInit(.fromInterned(ip.typeOf(val)), init: {
115264 if (!gop.found_existing) gop.value_ptr.* = .init(init: {
115265 const const_mcv = try cg.genTypedValue(.fromInterned(val));115257 const const_mcv = try cg.genTypedValue(.fromInterned(val));
115266 switch (const_mcv) {115258 switch (const_mcv) {
115267 .lea_tlv => |tlv_sym| switch (cg.bin_file.tag) {115259 .lea_tlv => |tlv_sym| switch (cg.bin_file.tag) {
...@@ -115289,7 +115281,6 @@ fn tempFromOperand(cg: *CodeGen, op_ref: Air.Inst.Ref, op_dies: bool) InnerError...@@ -115289,7 +115281,6 @@ fn tempFromOperand(cg: *CodeGen, op_ref: Air.Inst.Ref, op_dies: bool) InnerError
115289 else => break :init const_mcv,115281 else => break :init const_mcv,
115290 }115282 }
115291 });115283 });
115292 return cg.tempInit(.fromInterned(ip.typeOf(val)), gop.value_ptr.short);
115293}115284}
115294115285
115295fn tempsFromOperandsInner(115286fn tempsFromOperandsInner(