| ... | ... | @@ -1107,6 +1107,7 @@ fn formatWipMir( |
| 1107 | 1107 | .cc = .Unspecified, |
| 1108 | 1108 | .src_loc = data.self.src_loc, |
| 1109 | 1109 | }; |
| 1110 | var first = true; |
| 1110 | 1111 | for ((lower.lowerMir(data.inst) catch |err| switch (err) { |
| 1111 | 1112 | error.LowerFail => { |
| 1112 | 1113 | defer { |
| ... | ... | @@ -1125,7 +1126,11 @@ fn formatWipMir( |
| 1125 | 1126 | return; |
| 1126 | 1127 | }, |
| 1127 | 1128 | else => |e| return e, |
| 1128 | | }).insts) |lowered_inst| try writer.print(" | {}", .{lowered_inst}); |
| 1129 | }).insts) |lowered_inst| { |
| 1130 | if (!first) try writer.writeAll("\ndebug(wip_mir): "); |
| 1131 | try writer.print(" | {}", .{lowered_inst}); |
| 1132 | first = false; |
| 1133 | } |
| 1129 | 1134 | } |
| 1130 | 1135 | fn fmtWipMir(self: *Self, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMir) { |
| 1131 | 1136 | return .{ .data = .{ .self = self, .inst = inst } }; |
| ... | ... | @@ -15798,11 +15803,30 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue { |
| 15798 | 15803 | } else mcv: { |
| 15799 | 15804 | const ip_index = Air.refToInterned(ref).?; |
| 15800 | 15805 | const gop = try self.const_tracking.getOrPut(self.gpa, ip_index); |
| 15801 | | const mcv = try self.genTypedValue(.{ |
| 15802 | | .ty = ty, |
| 15803 | | .val = ip_index.toValue(), |
| 15806 | if (!gop.found_existing) gop.value_ptr.* = InstTracking.init(init: { |
| 15807 | const const_mcv = try self.genTypedValue(.{ .ty = ty, .val = ip_index.toValue() }); |
| 15808 | switch (const_mcv) { |
| 15809 | .lea_tlv => |tlv_sym| if (self.bin_file.cast(link.File.Elf)) |_| { |
| 15810 | if (self.bin_file.options.pic) { |
| 15811 | try self.spillRegisters(&.{ .rdi, .rax }); |
| 15812 | } else { |
| 15813 | try self.spillRegisters(&.{.rax}); |
| 15814 | } |
| 15815 | const frame_index = try self.allocFrameIndex(FrameAlloc.init(.{ |
| 15816 | .size = 8, |
| 15817 | .alignment = .@"8", |
| 15818 | })); |
| 15819 | try self.genSetMem( |
| 15820 | .{ .frame = frame_index }, |
| 15821 | 0, |
| 15822 | Type.usize, |
| 15823 | .{ .lea_symbol = .{ .sym = tlv_sym } }, |
| 15824 | ); |
| 15825 | break :init .{ .load_frame = .{ .index = frame_index } }; |
| 15826 | } else break :init const_mcv, |
| 15827 | else => break :init const_mcv, |
| 15828 | } |
| 15804 | 15829 | }); |
| 15805 | | if (!gop.found_existing) gop.value_ptr.* = InstTracking.init(mcv); |
| 15806 | 15830 | break :mcv gop.value_ptr.short; |
| 15807 | 15831 | }; |
| 15808 | 15832 | |