Commit 29051a0674

Andrew Kelley <andrew@ziglang.org>
2020-08-22 21:41:51
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 parent 2d40215
Changed files (1)
src-self-hosted
src-self-hosted/codegen.zig
@@ -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| {