diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-07-20 15:56:42 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-07-20 15:56:42 -0700 |
| commit | f47cf93b477c47cb4be00019203b2cd11a94d53d (patch) | |
| tree | 65b0f289e214e1ea9ed88ba8f027c1e928d3935e | |
| parent | 9c652cc6507e6cba9bba5403bd819676f23c93a1 (diff) | |
| download | zig-f47cf93b477c47cb4be00019203b2cd11a94d53d.tar.gz zig-f47cf93b477c47cb4be00019203b2cd11a94d53d.zip | |
stage2: C backend: fix ret AIR instruction
when operand has 0 runtime bits
| -rw-r--r-- | src/codegen/c.zig | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 71a0869046..71714cc1b8 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -1006,11 +1006,15 @@ fn airLoad(o: *Object, inst: Air.Inst.Index) !CValue { fn airRet(o: *Object, inst: Air.Inst.Index) !CValue { const un_op = o.air.instructions.items(.data)[inst].un_op; - const operand = try o.resolveInst(un_op); const writer = o.writer(); - try writer.writeAll("return "); - try o.writeCValue(writer, operand); - try writer.writeAll(";\n"); + if (o.air.typeOf(un_op).hasCodeGenBits()) { + const operand = try o.resolveInst(un_op); + try writer.writeAll("return "); + try o.writeCValue(writer, operand); + try writer.writeAll(";\n"); + } else { + try writer.writeAll("return;\n"); + } return CValue.none; } |
