authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-08-19 02:35:00+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-20 11:58:14-07:00
log7a85ad151daece3d0bba3c8d23081502a0956c95
tree4f11b16bdf5c0ae231df3b5463b32074389797b5
parent51f6438e076c0347197c251716174037a8465e91

cbe: elide block result allocation for 0-bit types

This logic already existed for the void type, but is also necessary for other 0-bit types. Without it, we try to alloc a local for a 0-bit type which gets translated to a local of type `void` which C doesn't like.

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

src/codegen/c.zig+1-1
......@@ -4285,7 +4285,7 @@ fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue {
42854285 const writer = f.object.writer();
42864286
42874287 const inst_ty = f.typeOfIndex(inst);
4288 const result = if (inst_ty.ip_index != .void_type and !f.liveness.isUnused(inst))
4288 const result = if (inst_ty.hasRuntimeBitsIgnoreComptime(mod) and !f.liveness.isUnused(inst))
42894289 try f.allocLocal(inst, inst_ty)
42904290 else
42914291 .none;