Skip to content

Commit f4a31be

Browse files
committed
x86_64: remove broken const value tracking
1 parent 1eb5d70 commit f4a31be

File tree

1 file changed

+27
-36
lines changed

1 file changed

+27
-36
lines changed

src/arch/x86_64/CodeGen.zig

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ end_di_column: u32,
8383
epilogue_relocs: std.ArrayListUnmanaged(Mir.Inst.Index) = .empty,
8484

8585
reused_operands: std.StaticBitSet(Liveness.bpi - 1) = undefined,
86-
const_tracking: ConstTrackingMap = .empty,
8786
inst_tracking: InstTrackingMap = .empty,
8887

8988
// Key is the block instruction
@@ -926,7 +925,6 @@ pub fn generate(
926925
while (block_it.next()) |block| block.deinit(gpa);
927926
function.blocks.deinit(gpa);
928927
function.inst_tracking.deinit(gpa);
929-
function.const_tracking.deinit(gpa);
930928
function.epilogue_relocs.deinit(gpa);
931929
function.mir_instructions.deinit(gpa);
932930
function.mir_extra.deinit(gpa);
@@ -108991,40 +108989,35 @@ fn resolveInst(self: *CodeGen, ref: Air.Inst.Ref) InnerError!MCValue {
108991108989
// If the type has no codegen bits, no need to store it.
108992108990
if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return .none;
108993108991

108994-
const mcv = if (ref.toIndex()) |inst| mcv: {
108992+
const mcv: MCValue = if (ref.toIndex()) |inst| mcv: {
108995108993
break :mcv self.inst_tracking.getPtr(inst).?.short;
108996108994
} else mcv: {
108997-
const ip_index = ref.toInterned().?;
108998-
const gop = try self.const_tracking.getOrPut(self.gpa, ip_index);
108999-
if (!gop.found_existing) gop.value_ptr.* = .init(init: {
109000-
const const_mcv = try self.genTypedValue(.fromInterned(ip_index));
109001-
switch (const_mcv) {
109002-
.lea_tlv => |tlv_sym| switch (self.bin_file.tag) {
109003-
.elf, .macho => {
109004-
if (self.mod.pic) {
109005-
try self.spillRegisters(&.{ .rdi, .rax });
109006-
} else {
109007-
try self.spillRegisters(&.{.rax});
109008-
}
109009-
const frame_index = try self.allocFrameIndex(.init(.{
109010-
.size = 8,
109011-
.alignment = .@"8",
109012-
}));
109013-
try self.genSetMem(
109014-
.{ .frame = frame_index },
109015-
0,
109016-
.usize,
109017-
.{ .lea_symbol = .{ .sym_index = tlv_sym } },
109018-
.{},
109019-
);
109020-
break :init .{ .load_frame = .{ .index = frame_index } };
109021-
},
109022-
else => break :init const_mcv,
108995+
const const_mcv = try self.genTypedValue(.fromInterned(ref.toInterned().?));
108996+
switch (const_mcv) {
108997+
.lea_tlv => |tlv_sym| switch (self.bin_file.tag) {
108998+
.elf, .macho => {
108999+
if (self.mod.pic) {
109000+
try self.spillRegisters(&.{ .rdi, .rax });
109001+
} else {
109002+
try self.spillRegisters(&.{.rax});
109003+
}
109004+
const frame_index = try self.allocFrameIndex(.init(.{
109005+
.size = 8,
109006+
.alignment = .@"8",
109007+
}));
109008+
try self.genSetMem(
109009+
.{ .frame = frame_index },
109010+
0,
109011+
.usize,
109012+
.{ .lea_symbol = .{ .sym_index = tlv_sym } },
109013+
.{},
109014+
);
109015+
break :mcv .{ .load_frame = .{ .index = frame_index } };
109023109016
},
109024-
else => break :init const_mcv,
109025-
}
109026-
});
109027-
break :mcv gop.value_ptr.short;
109017+
else => break :mcv const_mcv,
109018+
},
109019+
else => break :mcv const_mcv,
109020+
}
109028109021
};
109029109022

109030109023
switch (mcv) {
@@ -115260,8 +115253,7 @@ fn tempFromOperand(cg: *CodeGen, op_ref: Air.Inst.Ref, op_dies: bool) InnerError
115260115253

115261115254
if (op_ref.toIndex()) |op_inst| return .{ .index = op_inst };
115262115255
const val = op_ref.toInterned().?;
115263-
const gop = try cg.const_tracking.getOrPut(cg.gpa, val);
115264-
if (!gop.found_existing) gop.value_ptr.* = .init(init: {
115256+
return cg.tempInit(.fromInterned(ip.typeOf(val)), init: {
115265115257
const const_mcv = try cg.genTypedValue(.fromInterned(val));
115266115258
switch (const_mcv) {
115267115259
.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
115289115281
else => break :init const_mcv,
115290115282
}
115291115283
});
115292-
return cg.tempInit(.fromInterned(ip.typeOf(val)), gop.value_ptr.short);
115293115284
}
115294115285

115295115286
fn tempsFromOperandsInner(

0 commit comments

Comments
 (0)