Commit f4a31bed98

Jacob Young <jacobly0@users.noreply.github.com>
2025-03-27 03:50:22
x86_64: remove broken const value tracking
1 parent 1eb5d70
Changed files (1)
src
arch
src/arch/x86_64/CodeGen.zig
@@ -83,7 +83,6 @@ end_di_column: u32,
 epilogue_relocs: std.ArrayListUnmanaged(Mir.Inst.Index) = .empty,
 
 reused_operands: std.StaticBitSet(Liveness.bpi - 1) = undefined,
-const_tracking: ConstTrackingMap = .empty,
 inst_tracking: InstTrackingMap = .empty,
 
 // Key is the block instruction
@@ -926,7 +925,6 @@ pub fn generate(
         while (block_it.next()) |block| block.deinit(gpa);
         function.blocks.deinit(gpa);
         function.inst_tracking.deinit(gpa);
-        function.const_tracking.deinit(gpa);
         function.epilogue_relocs.deinit(gpa);
         function.mir_instructions.deinit(gpa);
         function.mir_extra.deinit(gpa);
@@ -108991,40 +108989,35 @@ fn resolveInst(self: *CodeGen, ref: Air.Inst.Ref) InnerError!MCValue {
     // If the type has no codegen bits, no need to store it.
     if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return .none;
 
-    const mcv = if (ref.toIndex()) |inst| mcv: {
+    const mcv: MCValue = if (ref.toIndex()) |inst| mcv: {
         break :mcv self.inst_tracking.getPtr(inst).?.short;
     } else mcv: {
-        const ip_index = ref.toInterned().?;
-        const gop = try self.const_tracking.getOrPut(self.gpa, ip_index);
-        if (!gop.found_existing) gop.value_ptr.* = .init(init: {
-            const const_mcv = try self.genTypedValue(.fromInterned(ip_index));
-            switch (const_mcv) {
-                .lea_tlv => |tlv_sym| switch (self.bin_file.tag) {
-                    .elf, .macho => {
-                        if (self.mod.pic) {
-                            try self.spillRegisters(&.{ .rdi, .rax });
-                        } else {
-                            try self.spillRegisters(&.{.rax});
-                        }
-                        const frame_index = try self.allocFrameIndex(.init(.{
-                            .size = 8,
-                            .alignment = .@"8",
-                        }));
-                        try self.genSetMem(
-                            .{ .frame = frame_index },
-                            0,
-                            .usize,
-                            .{ .lea_symbol = .{ .sym_index = tlv_sym } },
-                            .{},
-                        );
-                        break :init .{ .load_frame = .{ .index = frame_index } };
-                    },
-                    else => break :init const_mcv,
+        const const_mcv = try self.genTypedValue(.fromInterned(ref.toInterned().?));
+        switch (const_mcv) {
+            .lea_tlv => |tlv_sym| switch (self.bin_file.tag) {
+                .elf, .macho => {
+                    if (self.mod.pic) {
+                        try self.spillRegisters(&.{ .rdi, .rax });
+                    } else {
+                        try self.spillRegisters(&.{.rax});
+                    }
+                    const frame_index = try self.allocFrameIndex(.init(.{
+                        .size = 8,
+                        .alignment = .@"8",
+                    }));
+                    try self.genSetMem(
+                        .{ .frame = frame_index },
+                        0,
+                        .usize,
+                        .{ .lea_symbol = .{ .sym_index = tlv_sym } },
+                        .{},
+                    );
+                    break :mcv .{ .load_frame = .{ .index = frame_index } };
                 },
-                else => break :init const_mcv,
-            }
-        });
-        break :mcv gop.value_ptr.short;
+                else => break :mcv const_mcv,
+            },
+            else => break :mcv const_mcv,
+        }
     };
 
     switch (mcv) {
@@ -115260,8 +115253,7 @@ fn tempFromOperand(cg: *CodeGen, op_ref: Air.Inst.Ref, op_dies: bool) InnerError
 
     if (op_ref.toIndex()) |op_inst| return .{ .index = op_inst };
     const val = op_ref.toInterned().?;
-    const gop = try cg.const_tracking.getOrPut(cg.gpa, val);
-    if (!gop.found_existing) gop.value_ptr.* = .init(init: {
+    return cg.tempInit(.fromInterned(ip.typeOf(val)), init: {
         const const_mcv = try cg.genTypedValue(.fromInterned(val));
         switch (const_mcv) {
             .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
             else => break :init const_mcv,
         }
     });
-    return cg.tempInit(.fromInterned(ip.typeOf(val)), gop.value_ptr.short);
 }
 
 fn tempsFromOperandsInner(