authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-11-02 01:23:28-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-11-02 10:20:31-04:00
log5f31070b8bb204ce7d42881903805c7a4b2263d0
treec729a787cf2ce33fe30ed764e6e4fde8b2b6fc1e
parentd8635af1dcff8dc5fc4874a711d34bd67eeab689

cbe: hack around invalid Air

Can be changed to `!inst_ty.hisRuntimeBitsIgnoreComptime()` when the "result location with inferred type ends up being pointer to comptime_int" test stops producing Air containing a `bitcast(*comptime_int, ...)`. See #13410

2 files changed, 4 insertions(+), 5 deletions(-)

src/codegen/c.zig+4-4
...@@ -79,7 +79,6 @@ const BuiltinInfo = enum {...@@ -79,7 +79,6 @@ const BuiltinInfo = enum {
79 Bits,79 Bits,
80};80};
8181
82/// TODO make this not cut off at 128 bytes
83fn formatTypeAsCIdentifier(82fn formatTypeAsCIdentifier(
84 data: FormatTypeAsCIdentContext,83 data: FormatTypeAsCIdentContext,
85 comptime fmt: []const u8,84 comptime fmt: []const u8,
...@@ -3666,14 +3665,15 @@ fn airBr(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -3666,14 +3665,15 @@ fn airBr(f: *Function, inst: Air.Inst.Index) !CValue {
3666}3665}
36673666
3668fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {3667fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
3669 if (f.liveness.isUnused(inst))3668 const inst_ty = f.air.typeOfIndex(inst);
3670 return CValue.none;3669 // No IgnoreComptime until Sema stops giving us garbage Air.
3670 // https://github.com/ziglang/zig/issues/13410
3671 if (f.liveness.isUnused(inst) or !inst_ty.hasRuntimeBits()) return CValue.none;
36713672
3672 const ty_op = f.air.instructions.items(.data)[inst].ty_op;3673 const ty_op = f.air.instructions.items(.data)[inst].ty_op;
3673 const operand = try f.resolveInst(ty_op.operand);3674 const operand = try f.resolveInst(ty_op.operand);
36743675
3675 const writer = f.object.writer();3676 const writer = f.object.writer();
3676 const inst_ty = f.air.typeOfIndex(inst);
3677 if (inst_ty.isPtrAtRuntime() and3677 if (inst_ty.isPtrAtRuntime() and
3678 f.air.typeOf(ty_op.operand).isPtrAtRuntime())3678 f.air.typeOf(ty_op.operand).isPtrAtRuntime())
3679 {3679 {
test/behavior/if.zig-1
...@@ -146,7 +146,6 @@ test "result location with inferred type ends up being pointer to comptime_int"...@@ -146,7 +146,6 @@ test "result location with inferred type ends up being pointer to comptime_int"
146 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;146 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
147 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;147 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
148 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;148 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
149 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
150149
151 var a: ?u32 = 1234;150 var a: ?u32 = 1234;
152 var b: u32 = 2000;151 var b: u32 = 2000;