riscv64: Handle writes to the zero register sensibly in result bookkeeping.

This commit is contained in:
Alex Rønne Petersen 2024-11-02 08:59:14 +01:00
parent dfd203609d
commit cc507c5024
No known key found for this signature in database

View File

@ -1811,8 +1811,15 @@ fn finishAirBookkeeping(func: *Func) void {
fn finishAirResult(func: *Func, inst: Air.Inst.Index, result: MCValue) void {
if (func.liveness.isUnused(inst)) switch (result) {
.none, .dead, .unreach => {},
else => unreachable, // Why didn't the result die?
// Why didn't the result die?
.register => |r| if (r != .zero) unreachable,
else => unreachable,
} else {
switch (result) {
.register => |r| if (r == .zero) unreachable, // Why did we discard a used result?
else => {},
}
tracking_log.debug("%{d} => {} (birth)", .{ inst, result });
func.inst_tracking.putAssumeCapacityNoClobber(inst, InstTracking.init(result));
// In some cases, an operand may be reused as the result.