Commit f47cf93b47

Andrew Kelley <andrew@ziglang.org>
2021-07-21 00:56:42
stage2: C backend: fix ret AIR instruction
when operand has 0 runtime bits
1 parent 9c652cc
Changed files (1)
src
codegen
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;
 }