aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-11-02 01:23:28 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2022-11-02 10:20:31 -0400
commit5f31070b8bb204ce7d42881903805c7a4b2263d0 (patch)
treec729a787cf2ce33fe30ed764e6e4fde8b2b6fc1e /src/codegen
parentd8635af1dcff8dc5fc4874a711d34bd67eeab689 (diff)
downloadzig-5f31070b8bb204ce7d42881903805c7a4b2263d0.tar.gz
zig-5f31070b8bb204ce7d42881903805c7a4b2263d0.zip
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
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 2762123b64..f3fdb6ae89 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -79,7 +79,6 @@ const BuiltinInfo = enum {
Bits,
};
-/// TODO make this not cut off at 128 bytes
fn formatTypeAsCIdentifier(
data: FormatTypeAsCIdentContext,
comptime fmt: []const u8,
@@ -3666,14 +3665,15 @@ fn airBr(f: *Function, inst: Air.Inst.Index) !CValue {
}
fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
- if (f.liveness.isUnused(inst))
- return CValue.none;
+ const inst_ty = f.air.typeOfIndex(inst);
+ // No IgnoreComptime until Sema stops giving us garbage Air.
+ // https://github.com/ziglang/zig/issues/13410
+ if (f.liveness.isUnused(inst) or !inst_ty.hasRuntimeBits()) return CValue.none;
const ty_op = f.air.instructions.items(.data)[inst].ty_op;
const operand = try f.resolveInst(ty_op.operand);
const writer = f.object.writer();
- const inst_ty = f.air.typeOfIndex(inst);
if (inst_ty.isPtrAtRuntime() and
f.air.typeOf(ty_op.operand).isPtrAtRuntime())
{