authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-22 12:41:51-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-22 12:44:45-07:00
log29051a0674800881957479c423a1feb043391671
tree0a3fddfb551f22b15898a7539d7eb187f26f542d
parent2d402157d9e6ea34499604455cf1270ef7eb5a1f

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.

1 files changed, 3 insertions(+), 2 deletions(-)

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