stage2: codegen: fix crash

I forgot to do -Denable-qemu -Denable-wasmtime when testing yesterday,
sorry about that.

In reuseOperand, the code assumed a re-used register would be tracked in
the register table but that is not always the case.
This commit is contained in:
Andrew Kelley
2020-08-22 12:41:51 -07:00
parent 2d402157d9
commit 29051a0674

View File

@@ -934,8 +934,9 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
// If it's in the registers table, need to associate the register with the
// new instruction.
const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];
const entry = branch.registers.getEntry(toCanonicalReg(reg)).?;
entry.value = .{ .inst = inst };
if (branch.registers.getEntry(toCanonicalReg(reg))) |entry| {
entry.value = .{ .inst = inst };
}
log.debug("reusing {} => {*}", .{reg, inst});
},
.stack_offset => |off| {