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 {
7979 Bits,
8080};
8181
82/// TODO make this not cut off at 128 bytes
8382fn formatTypeAsCIdentifier(
8483 data: FormatTypeAsCIdentContext,
8584 comptime fmt: []const u8,
......@@ -3666,14 +3665,15 @@ fn airBr(f: *Function, inst: Air.Inst.Index) !CValue {
36663665}
36673666
36683667fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
3669 if (f.liveness.isUnused(inst))
3670 return CValue.none;
3668 const inst_ty = f.air.typeOfIndex(inst);
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
36723673 const ty_op = f.air.instructions.items(.data)[inst].ty_op;
36733674 const operand = try f.resolveInst(ty_op.operand);
36743675
36753676 const writer = f.object.writer();
3676 const inst_ty = f.air.typeOfIndex(inst);
36773677 if (inst_ty.isPtrAtRuntime() and
36783678 f.air.typeOf(ty_op.operand).isPtrAtRuntime())
36793679 {
test/behavior/if.zig-1
......@@ -146,7 +146,6 @@ test "result location with inferred type ends up being pointer to comptime_int"
146146 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
147147 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
148148 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
149 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
150149
151150 var a: ?u32 = 1234;
152151 var b: u32 = 2000;