authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-11 22:48:35-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-11 22:48:35-07:00
logf6b479b81d3e893f1240a2fc03397d519987f850
tree42967bd3a09fedb70dfb9ce5f9bfae05b27cf8df
parent98c950827f9e57ab4736140eede61eac6858157f

LLVM: use hasRuntimeBitsIgnoreComptime instead of hasRuntimeBits

LLVM codegen doesn't care whether types are comptime or not. Comptime types aren't supposed to make it to codegen anyway.

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

src/codegen/llvm.zig+51-51
...@@ -558,7 +558,7 @@ pub const Object = struct {...@@ -558,7 +558,7 @@ pub const Object = struct {
558558
559 const param_offset: c_uint = @boolToInt(ret_ptr != null);559 const param_offset: c_uint = @boolToInt(ret_ptr != null);
560 for (fn_info.param_types) |param_ty| {560 for (fn_info.param_types) |param_ty| {
561 if (!param_ty.hasRuntimeBits()) continue;561 if (!param_ty.hasRuntimeBitsIgnoreComptime()) continue;
562562
563 const llvm_arg_i = @intCast(c_uint, args.items.len) + param_offset;563 const llvm_arg_i = @intCast(c_uint, args.items.len) + param_offset;
564 try args.append(llvm_func.getParam(llvm_arg_i));564 try args.append(llvm_func.getParam(llvm_arg_i));
...@@ -878,7 +878,7 @@ pub const DeclGen = struct {...@@ -878,7 +878,7 @@ pub const DeclGen = struct {
878 // Set parameter attributes.878 // Set parameter attributes.
879 var llvm_param_i: c_uint = @boolToInt(sret);879 var llvm_param_i: c_uint = @boolToInt(sret);
880 for (fn_info.param_types) |param_ty| {880 for (fn_info.param_types) |param_ty| {
881 if (!param_ty.hasRuntimeBits()) continue;881 if (!param_ty.hasRuntimeBitsIgnoreComptime()) continue;
882882
883 if (isByRef(param_ty)) {883 if (isByRef(param_ty)) {
884 dg.addArgAttr(llvm_fn, llvm_param_i, "nonnull");884 dg.addArgAttr(llvm_fn, llvm_param_i, "nonnull");
...@@ -1078,7 +1078,7 @@ pub const DeclGen = struct {...@@ -1078,7 +1078,7 @@ pub const DeclGen = struct {
1078 .Optional => {1078 .Optional => {
1079 var buf: Type.Payload.ElemType = undefined;1079 var buf: Type.Payload.ElemType = undefined;
1080 const child_ty = t.optionalChild(&buf);1080 const child_ty = t.optionalChild(&buf);
1081 if (!child_ty.hasRuntimeBits()) {1081 if (!child_ty.hasRuntimeBitsIgnoreComptime()) {
1082 return dg.context.intType(1);1082 return dg.context.intType(1);
1083 }1083 }
1084 const payload_llvm_ty = try dg.llvmType(child_ty);1084 const payload_llvm_ty = try dg.llvmType(child_ty);
...@@ -1095,7 +1095,7 @@ pub const DeclGen = struct {...@@ -1095,7 +1095,7 @@ pub const DeclGen = struct {
1095 const error_type = t.errorUnionSet();1095 const error_type = t.errorUnionSet();
1096 const payload_type = t.errorUnionPayload();1096 const payload_type = t.errorUnionPayload();
1097 const llvm_error_type = try dg.llvmType(error_type);1097 const llvm_error_type = try dg.llvmType(error_type);
1098 if (!payload_type.hasRuntimeBits()) {1098 if (!payload_type.hasRuntimeBitsIgnoreComptime()) {
1099 return llvm_error_type;1099 return llvm_error_type;
1100 }1100 }
1101 const llvm_payload_type = try dg.llvmType(payload_type);1101 const llvm_payload_type = try dg.llvmType(payload_type);
...@@ -1194,7 +1194,7 @@ pub const DeclGen = struct {...@@ -1194,7 +1194,7 @@ pub const DeclGen = struct {
1194 var big_align: u32 = 0;1194 var big_align: u32 = 0;
11951195
1196 for (struct_obj.fields.values()) |field| {1196 for (struct_obj.fields.values()) |field| {
1197 if (field.is_comptime or !field.ty.hasRuntimeBits()) continue;1197 if (field.is_comptime or !field.ty.hasRuntimeBitsIgnoreComptime()) continue;
11981198
1199 const field_align = field.normalAlignment(target);1199 const field_align = field.normalAlignment(target);
1200 big_align = @maximum(big_align, field_align);1200 big_align = @maximum(big_align, field_align);
...@@ -1298,7 +1298,7 @@ pub const DeclGen = struct {...@@ -1298,7 +1298,7 @@ pub const DeclGen = struct {
1298 const fn_info = t.fnInfo();1298 const fn_info = t.fnInfo();
1299 const sret = firstParamSRet(fn_info, target);1299 const sret = firstParamSRet(fn_info, target);
1300 const return_type = fn_info.return_type;1300 const return_type = fn_info.return_type;
1301 const llvm_sret_ty = if (return_type.hasRuntimeBits())1301 const llvm_sret_ty = if (return_type.hasRuntimeBitsIgnoreComptime())
1302 try dg.llvmType(return_type)1302 try dg.llvmType(return_type)
1303 else1303 else
1304 dg.context.voidType();1304 dg.context.voidType();
...@@ -1312,7 +1312,7 @@ pub const DeclGen = struct {...@@ -1312,7 +1312,7 @@ pub const DeclGen = struct {
1312 }1312 }
13131313
1314 for (fn_info.param_types) |param_ty| {1314 for (fn_info.param_types) |param_ty| {
1315 if (!param_ty.hasRuntimeBits()) continue;1315 if (!param_ty.hasRuntimeBitsIgnoreComptime()) continue;
13161316
1317 const raw_llvm_ty = try dg.llvmType(param_ty);1317 const raw_llvm_ty = try dg.llvmType(param_ty);
1318 const actual_llvm_ty = if (!isByRef(param_ty)) raw_llvm_ty else raw_llvm_ty.pointerType(0);1318 const actual_llvm_ty = if (!isByRef(param_ty)) raw_llvm_ty else raw_llvm_ty.pointerType(0);
...@@ -1592,7 +1592,7 @@ pub const DeclGen = struct {...@@ -1592,7 +1592,7 @@ pub const DeclGen = struct {
1592 const llvm_i1 = dg.context.intType(1);1592 const llvm_i1 = dg.context.intType(1);
1593 const is_pl = !tv.val.isNull();1593 const is_pl = !tv.val.isNull();
1594 const non_null_bit = if (is_pl) llvm_i1.constAllOnes() else llvm_i1.constNull();1594 const non_null_bit = if (is_pl) llvm_i1.constAllOnes() else llvm_i1.constNull();
1595 if (!payload_ty.hasRuntimeBits()) {1595 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
1596 return non_null_bit;1596 return non_null_bit;
1597 }1597 }
1598 if (tv.ty.isPtrLikeOptional()) {1598 if (tv.ty.isPtrLikeOptional()) {
...@@ -1643,7 +1643,7 @@ pub const DeclGen = struct {...@@ -1643,7 +1643,7 @@ pub const DeclGen = struct {
1643 const payload_type = tv.ty.errorUnionPayload();1643 const payload_type = tv.ty.errorUnionPayload();
1644 const is_pl = tv.val.errorUnionIsPayload();1644 const is_pl = tv.val.errorUnionIsPayload();
16451645
1646 if (!payload_type.hasRuntimeBits()) {1646 if (!payload_type.hasRuntimeBitsIgnoreComptime()) {
1647 // We use the error type directly as the type.1647 // We use the error type directly as the type.
1648 const err_val = if (!is_pl) tv.val else Value.initTag(.zero);1648 const err_val = if (!is_pl) tv.val else Value.initTag(.zero);
1649 return dg.genTypedValue(.{ .ty = error_type, .val = err_val });1649 return dg.genTypedValue(.{ .ty = error_type, .val = err_val });
...@@ -1677,7 +1677,7 @@ pub const DeclGen = struct {...@@ -1677,7 +1677,7 @@ pub const DeclGen = struct {
1677 var running_bits: u16 = 0;1677 var running_bits: u16 = 0;
1678 for (field_vals) |field_val, i| {1678 for (field_vals) |field_val, i| {
1679 const field = fields[i];1679 const field = fields[i];
1680 if (!field.ty.hasRuntimeBits()) continue;1680 if (!field.ty.hasRuntimeBitsIgnoreComptime()) continue;
16811681
1682 const non_int_val = try dg.genTypedValue(.{1682 const non_int_val = try dg.genTypedValue(.{
1683 .ty = field.ty,1683 .ty = field.ty,
...@@ -1708,7 +1708,7 @@ pub const DeclGen = struct {...@@ -1708,7 +1708,7 @@ pub const DeclGen = struct {
17081708
1709 var need_unnamed = false;1709 var need_unnamed = false;
1710 for (struct_obj.fields.values()) |field, i| {1710 for (struct_obj.fields.values()) |field, i| {
1711 if (field.is_comptime or !field.ty.hasRuntimeBits()) continue;1711 if (field.is_comptime or !field.ty.hasRuntimeBitsIgnoreComptime()) continue;
17121712
1713 const field_align = field.normalAlignment(target);1713 const field_align = field.normalAlignment(target);
1714 big_align = @maximum(big_align, field_align);1714 big_align = @maximum(big_align, field_align);
...@@ -1775,7 +1775,7 @@ pub const DeclGen = struct {...@@ -1775,7 +1775,7 @@ pub const DeclGen = struct {
1775 assert(union_obj.haveFieldTypes());1775 assert(union_obj.haveFieldTypes());
1776 const field_ty = union_obj.fields.values()[field_index].ty;1776 const field_ty = union_obj.fields.values()[field_index].ty;
1777 const payload = p: {1777 const payload = p: {
1778 if (!field_ty.hasRuntimeBits()) {1778 if (!field_ty.hasRuntimeBitsIgnoreComptime()) {
1779 const padding_len = @intCast(c_uint, layout.payload_size);1779 const padding_len = @intCast(c_uint, layout.payload_size);
1780 break :p dg.context.intType(8).arrayType(padding_len).getUndef();1780 break :p dg.context.intType(8).arrayType(padding_len).getUndef();
1781 }1781 }
...@@ -1936,7 +1936,7 @@ pub const DeclGen = struct {...@@ -1936,7 +1936,7 @@ pub const DeclGen = struct {
1936 .Enum => {1936 .Enum => {
1937 const owner_decl = ty.getOwnerDecl();1937 const owner_decl = ty.getOwnerDecl();
19381938
1939 if (!ty.hasRuntimeBits()) {1939 if (!ty.hasRuntimeBitsIgnoreComptime()) {
1940 const enum_di_ty = try dg.makeEmptyNamespaceDIType(owner_decl);1940 const enum_di_ty = try dg.makeEmptyNamespaceDIType(owner_decl);
1941 // The recursive call to `lowerDebugType` via `makeEmptyNamespaceDIType`1941 // The recursive call to `lowerDebugType` via `makeEmptyNamespaceDIType`
1942 // means we can't use `gop` anymore.1942 // means we can't use `gop` anymore.
...@@ -2178,7 +2178,7 @@ pub const DeclGen = struct {...@@ -2178,7 +2178,7 @@ pub const DeclGen = struct {
2178 defer gpa.free(name);2178 defer gpa.free(name);
2179 var buf: Type.Payload.ElemType = undefined;2179 var buf: Type.Payload.ElemType = undefined;
2180 const child_ty = ty.optionalChild(&buf);2180 const child_ty = ty.optionalChild(&buf);
2181 if (!child_ty.hasRuntimeBits()) {2181 if (!child_ty.hasRuntimeBitsIgnoreComptime()) {
2182 gop.value_ptr.* = dib.createBasicType(name, 1, DW.ATE.boolean);2182 gop.value_ptr.* = dib.createBasicType(name, 1, DW.ATE.boolean);
2183 return gop.value_ptr.*;2183 return gop.value_ptr.*;
2184 }2184 }
...@@ -2260,7 +2260,7 @@ pub const DeclGen = struct {...@@ -2260,7 +2260,7 @@ pub const DeclGen = struct {
2260 .ErrorUnion => {2260 .ErrorUnion => {
2261 const err_set_ty = ty.errorUnionSet();2261 const err_set_ty = ty.errorUnionSet();
2262 const payload_ty = ty.errorUnionPayload();2262 const payload_ty = ty.errorUnionPayload();
2263 if (!payload_ty.hasRuntimeBits()) {2263 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
2264 const err_set_di_ty = try dg.lowerDebugType(err_set_ty);2264 const err_set_di_ty = try dg.lowerDebugType(err_set_ty);
2265 // The recursive call to `lowerDebugType` means we can't use `gop` anymore.2265 // The recursive call to `lowerDebugType` means we can't use `gop` anymore.
2266 try dg.object.di_type_map.put(gpa, ty, err_set_di_ty);2266 try dg.object.di_type_map.put(gpa, ty, err_set_di_ty);
...@@ -2415,7 +2415,7 @@ pub const DeclGen = struct {...@@ -2415,7 +2415,7 @@ pub const DeclGen = struct {
2415 }2415 }
24162416
2417 const TODO_implement_this = true; // TODO2417 const TODO_implement_this = true; // TODO
2418 if (TODO_implement_this or !ty.hasRuntimeBits()) {2418 if (TODO_implement_this or !ty.hasRuntimeBitsIgnoreComptime()) {
2419 const owner_decl = ty.getOwnerDecl();2419 const owner_decl = ty.getOwnerDecl();
2420 const struct_di_ty = try dg.makeEmptyNamespaceDIType(owner_decl);2420 const struct_di_ty = try dg.makeEmptyNamespaceDIType(owner_decl);
2421 dib.replaceTemporary(fwd_decl, struct_di_ty);2421 dib.replaceTemporary(fwd_decl, struct_di_ty);
...@@ -2454,7 +2454,7 @@ pub const DeclGen = struct {...@@ -2454,7 +2454,7 @@ pub const DeclGen = struct {
2454 //var big_align: u32 = 0;2454 //var big_align: u32 = 0;
24552455
2456 //for (struct_obj.fields.values()) |field| {2456 //for (struct_obj.fields.values()) |field| {
2457 // if (field.is_comptime or !field.ty.hasRuntimeBits()) continue;2457 // if (field.is_comptime or !field.ty.hasRuntimeBitsIgnoreComptime()) continue;
24582458
2459 // const field_align = field.normalAlignment(target);2459 // const field_align = field.normalAlignment(target);
2460 // big_align = @maximum(big_align, field_align);2460 // big_align = @maximum(big_align, field_align);
...@@ -2504,7 +2504,7 @@ pub const DeclGen = struct {...@@ -2504,7 +2504,7 @@ pub const DeclGen = struct {
2504 gop.value_ptr.* = fwd_decl;2504 gop.value_ptr.* = fwd_decl;
25052505
2506 const TODO_implement_this = true; // TODO2506 const TODO_implement_this = true; // TODO
2507 if (TODO_implement_this or !ty.hasRuntimeBits()) {2507 if (TODO_implement_this or !ty.hasRuntimeBitsIgnoreComptime()) {
2508 const union_di_ty = try dg.makeEmptyNamespaceDIType(owner_decl);2508 const union_di_ty = try dg.makeEmptyNamespaceDIType(owner_decl);
2509 dib.replaceTemporary(fwd_decl, union_di_ty);2509 dib.replaceTemporary(fwd_decl, union_di_ty);
2510 // The recursive call to `lowerDebugType` via `makeEmptyNamespaceDIType`2510 // The recursive call to `lowerDebugType` via `makeEmptyNamespaceDIType`
...@@ -2586,7 +2586,7 @@ pub const DeclGen = struct {...@@ -2586,7 +2586,7 @@ pub const DeclGen = struct {
2586 defer param_di_types.deinit();2586 defer param_di_types.deinit();
25872587
2588 // Return type goes first.2588 // Return type goes first.
2589 const di_ret_ty = if (sret or !fn_info.return_type.hasRuntimeBits())2589 const di_ret_ty = if (sret or !fn_info.return_type.hasRuntimeBitsIgnoreComptime())
2590 Type.void2590 Type.void
2591 else2591 else
2592 fn_info.return_type;2592 fn_info.return_type;
...@@ -2602,7 +2602,7 @@ pub const DeclGen = struct {...@@ -2602,7 +2602,7 @@ pub const DeclGen = struct {
2602 }2602 }
26032603
2604 for (fn_info.param_types) |param_ty| {2604 for (fn_info.param_types) |param_ty| {
2605 if (!param_ty.hasRuntimeBits()) continue;2605 if (!param_ty.hasRuntimeBitsIgnoreComptime()) continue;
26062606
2607 if (isByRef(param_ty)) {2607 if (isByRef(param_ty)) {
2608 var ptr_ty_payload: Type.Payload.ElemType = .{2608 var ptr_ty_payload: Type.Payload.ElemType = .{
...@@ -2793,7 +2793,7 @@ pub const DeclGen = struct {...@@ -2793,7 +2793,7 @@ pub const DeclGen = struct {
2793 const parent = try dg.lowerParentPtr(opt_payload_ptr, base_ty);2793 const parent = try dg.lowerParentPtr(opt_payload_ptr, base_ty);
2794 var buf: Type.Payload.ElemType = undefined;2794 var buf: Type.Payload.ElemType = undefined;
2795 const payload_ty = parent.ty.optionalChild(&buf);2795 const payload_ty = parent.ty.optionalChild(&buf);
2796 if (!payload_ty.hasRuntimeBits() or parent.ty.isPtrLikeOptional()) {2796 if (!payload_ty.hasRuntimeBitsIgnoreComptime() or parent.ty.isPtrLikeOptional()) {
2797 // In this case, we represent pointer to optional the same as pointer2797 // In this case, we represent pointer to optional the same as pointer
2798 // to the payload.2798 // to the payload.
2799 return ParentPtr{2799 return ParentPtr{
...@@ -2816,7 +2816,7 @@ pub const DeclGen = struct {...@@ -2816,7 +2816,7 @@ pub const DeclGen = struct {
2816 const eu_payload_ptr = ptr_val.castTag(.eu_payload_ptr).?.data;2816 const eu_payload_ptr = ptr_val.castTag(.eu_payload_ptr).?.data;
2817 const parent = try dg.lowerParentPtr(eu_payload_ptr, base_ty);2817 const parent = try dg.lowerParentPtr(eu_payload_ptr, base_ty);
2818 const payload_ty = parent.ty.errorUnionPayload();2818 const payload_ty = parent.ty.errorUnionPayload();
2819 if (!payload_ty.hasRuntimeBits()) {2819 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
2820 // In this case, we represent pointer to error union the same as pointer2820 // In this case, we represent pointer to error union the same as pointer
2821 // to the payload.2821 // to the payload.
2822 return ParentPtr{2822 return ParentPtr{
...@@ -2865,7 +2865,7 @@ pub const DeclGen = struct {...@@ -2865,7 +2865,7 @@ pub const DeclGen = struct {
2865 }2865 }
28662866
2867 const is_fn_body = decl.ty.zigTypeTag() == .Fn;2867 const is_fn_body = decl.ty.zigTypeTag() == .Fn;
2868 if (!is_fn_body and !decl.ty.hasRuntimeBits()) {2868 if (!is_fn_body and !decl.ty.hasRuntimeBitsIgnoreComptime()) {
2869 return self.lowerPtrToVoid(tv.ty);2869 return self.lowerPtrToVoid(tv.ty);
2870 }2870 }
28712871
...@@ -3298,7 +3298,7 @@ pub const FuncGen = struct {...@@ -3298,7 +3298,7 @@ pub const FuncGen = struct {
3298 } else {3298 } else {
3299 for (args) |arg, i| {3299 for (args) |arg, i| {
3300 const param_ty = fn_info.param_types[i];3300 const param_ty = fn_info.param_types[i];
3301 if (!param_ty.hasRuntimeBits()) continue;3301 if (!param_ty.hasRuntimeBitsIgnoreComptime()) continue;
33023302
3303 try llvm_args.append(try self.resolveInst(arg));3303 try llvm_args.append(try self.resolveInst(arg));
3304 }3304 }
...@@ -3318,7 +3318,7 @@ pub const FuncGen = struct {...@@ -3318,7 +3318,7 @@ pub const FuncGen = struct {
3318 return null;3318 return null;
3319 }3319 }
33203320
3321 if (self.liveness.isUnused(inst) or !return_type.hasRuntimeBits()) {3321 if (self.liveness.isUnused(inst) or !return_type.hasRuntimeBitsIgnoreComptime()) {
3322 return null;3322 return null;
3323 }3323 }
33243324
...@@ -3364,7 +3364,7 @@ pub const FuncGen = struct {...@@ -3364,7 +3364,7 @@ pub const FuncGen = struct {
3364 _ = self.builder.buildRetVoid();3364 _ = self.builder.buildRetVoid();
3365 return null;3365 return null;
3366 }3366 }
3367 if (!ret_ty.hasRuntimeBits()) {3367 if (!ret_ty.hasRuntimeBitsIgnoreComptime()) {
3368 _ = self.builder.buildRetVoid();3368 _ = self.builder.buildRetVoid();
3369 return null;3369 return null;
3370 }3370 }
...@@ -3377,7 +3377,7 @@ pub const FuncGen = struct {...@@ -3377,7 +3377,7 @@ pub const FuncGen = struct {
3377 const un_op = self.air.instructions.items(.data)[inst].un_op;3377 const un_op = self.air.instructions.items(.data)[inst].un_op;
3378 const ptr_ty = self.air.typeOf(un_op);3378 const ptr_ty = self.air.typeOf(un_op);
3379 const ret_ty = ptr_ty.childType();3379 const ret_ty = ptr_ty.childType();
3380 if (!ret_ty.hasRuntimeBits() or self.ret_ptr != null) {3380 if (!ret_ty.hasRuntimeBitsIgnoreComptime() or self.ret_ptr != null) {
3381 _ = self.builder.buildRetVoid();3381 _ = self.builder.buildRetVoid();
3382 return null;3382 return null;
3383 }3383 }
...@@ -3415,7 +3415,7 @@ pub const FuncGen = struct {...@@ -3415,7 +3415,7 @@ pub const FuncGen = struct {
3415 .Int, .Bool, .Pointer, .ErrorSet => operand_ty,3415 .Int, .Bool, .Pointer, .ErrorSet => operand_ty,
3416 .Optional => blk: {3416 .Optional => blk: {
3417 const payload_ty = operand_ty.optionalChild(&opt_buffer);3417 const payload_ty = operand_ty.optionalChild(&opt_buffer);
3418 if (!payload_ty.hasRuntimeBits() or operand_ty.isPtrLikeOptional()) {3418 if (!payload_ty.hasRuntimeBitsIgnoreComptime() or operand_ty.isPtrLikeOptional()) {
3419 break :blk operand_ty;3419 break :blk operand_ty;
3420 }3420 }
3421 // We need to emit instructions to check for equality/inequality3421 // We need to emit instructions to check for equality/inequality
...@@ -3540,7 +3540,7 @@ pub const FuncGen = struct {...@@ -3540,7 +3540,7 @@ pub const FuncGen = struct {
35403540
3541 // If the block does not return a value, we dont have to create a phi node.3541 // If the block does not return a value, we dont have to create a phi node.
3542 const is_body = inst_ty.zigTypeTag() == .Fn;3542 const is_body = inst_ty.zigTypeTag() == .Fn;
3543 if (!is_body and !inst_ty.hasRuntimeBits()) return null;3543 if (!is_body and !inst_ty.hasRuntimeBitsIgnoreComptime()) return null;
35443544
3545 const raw_llvm_ty = try self.dg.llvmType(inst_ty);3545 const raw_llvm_ty = try self.dg.llvmType(inst_ty);
35463546
...@@ -3571,7 +3571,7 @@ pub const FuncGen = struct {...@@ -3571,7 +3571,7 @@ pub const FuncGen = struct {
3571 // If the break doesn't break a value, then we don't have to add3571 // If the break doesn't break a value, then we don't have to add
3572 // the values to the lists.3572 // the values to the lists.
3573 const operand_ty = self.air.typeOf(branch.operand);3573 const operand_ty = self.air.typeOf(branch.operand);
3574 if (operand_ty.hasRuntimeBits() or operand_ty.zigTypeTag() == .Fn) {3574 if (operand_ty.hasRuntimeBitsIgnoreComptime() or operand_ty.zigTypeTag() == .Fn) {
3575 const val = try self.resolveInst(branch.operand);3575 const val = try self.resolveInst(branch.operand);
35763576
3577 // For the phi node, we need the basic blocks and the values of the3577 // For the phi node, we need the basic blocks and the values of the
...@@ -3685,7 +3685,7 @@ pub const FuncGen = struct {...@@ -3685,7 +3685,7 @@ pub const FuncGen = struct {
3685 const llvm_usize = try self.dg.llvmType(Type.usize);3685 const llvm_usize = try self.dg.llvmType(Type.usize);
3686 const len = llvm_usize.constInt(array_ty.arrayLen(), .False);3686 const len = llvm_usize.constInt(array_ty.arrayLen(), .False);
3687 const slice_llvm_ty = try self.dg.llvmType(self.air.typeOfIndex(inst));3687 const slice_llvm_ty = try self.dg.llvmType(self.air.typeOfIndex(inst));
3688 if (!array_ty.hasRuntimeBits()) {3688 if (!array_ty.hasRuntimeBitsIgnoreComptime()) {
3689 return self.builder.buildInsertValue(slice_llvm_ty.getUndef(), len, 1, "");3689 return self.builder.buildInsertValue(slice_llvm_ty.getUndef(), len, 1, "");
3690 }3690 }
3691 const operand = try self.resolveInst(ty_op.operand);3691 const operand = try self.resolveInst(ty_op.operand);
...@@ -3816,7 +3816,7 @@ pub const FuncGen = struct {...@@ -3816,7 +3816,7 @@ pub const FuncGen = struct {
3816 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;3816 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
3817 const ptr_ty = self.air.typeOf(bin_op.lhs);3817 const ptr_ty = self.air.typeOf(bin_op.lhs);
3818 const elem_ty = ptr_ty.childType();3818 const elem_ty = ptr_ty.childType();
3819 if (!elem_ty.hasRuntimeBits()) return self.dg.lowerPtrToVoid(ptr_ty);3819 if (!elem_ty.hasRuntimeBitsIgnoreComptime()) return self.dg.lowerPtrToVoid(ptr_ty);
38203820
3821 const base_ptr = try self.resolveInst(bin_op.lhs);3821 const base_ptr = try self.resolveInst(bin_op.lhs);
3822 const rhs = try self.resolveInst(bin_op.rhs);3822 const rhs = try self.resolveInst(bin_op.rhs);
...@@ -3863,7 +3863,7 @@ pub const FuncGen = struct {...@@ -3863,7 +3863,7 @@ pub const FuncGen = struct {
3863 const struct_llvm_val = try self.resolveInst(struct_field.struct_operand);3863 const struct_llvm_val = try self.resolveInst(struct_field.struct_operand);
3864 const field_index = struct_field.field_index;3864 const field_index = struct_field.field_index;
3865 const field_ty = struct_ty.structFieldType(field_index);3865 const field_ty = struct_ty.structFieldType(field_index);
3866 if (!field_ty.hasRuntimeBits()) {3866 if (!field_ty.hasRuntimeBitsIgnoreComptime()) {
3867 return null;3867 return null;
3868 }3868 }
3869 const target = self.dg.module.getTarget();3869 const target = self.dg.module.getTarget();
...@@ -4152,7 +4152,7 @@ pub const FuncGen = struct {...@@ -4152,7 +4152,7 @@ pub const FuncGen = struct {
41524152
4153 var buf: Type.Payload.ElemType = undefined;4153 var buf: Type.Payload.ElemType = undefined;
4154 const payload_ty = optional_ty.optionalChild(&buf);4154 const payload_ty = optional_ty.optionalChild(&buf);
4155 if (!payload_ty.hasRuntimeBits()) {4155 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
4156 if (invert) {4156 if (invert) {
4157 return self.builder.buildNot(operand, "");4157 return self.builder.buildNot(operand, "");
4158 } else {4158 } else {
...@@ -4184,7 +4184,7 @@ pub const FuncGen = struct {...@@ -4184,7 +4184,7 @@ pub const FuncGen = struct {
4184 const err_set_ty = try self.dg.llvmType(Type.initTag(.anyerror));4184 const err_set_ty = try self.dg.llvmType(Type.initTag(.anyerror));
4185 const zero = err_set_ty.constNull();4185 const zero = err_set_ty.constNull();
41864186
4187 if (!payload_ty.hasRuntimeBits()) {4187 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
4188 const loaded = if (operand_is_ptr) self.builder.buildLoad(operand, "") else operand;4188 const loaded = if (operand_is_ptr) self.builder.buildLoad(operand, "") else operand;
4189 return self.builder.buildICmp(op, loaded, zero, "");4189 return self.builder.buildICmp(op, loaded, zero, "");
4190 }4190 }
...@@ -4207,7 +4207,7 @@ pub const FuncGen = struct {...@@ -4207,7 +4207,7 @@ pub const FuncGen = struct {
4207 const optional_ty = self.air.typeOf(ty_op.operand).childType();4207 const optional_ty = self.air.typeOf(ty_op.operand).childType();
4208 var buf: Type.Payload.ElemType = undefined;4208 var buf: Type.Payload.ElemType = undefined;
4209 const payload_ty = optional_ty.optionalChild(&buf);4209 const payload_ty = optional_ty.optionalChild(&buf);
4210 if (!payload_ty.hasRuntimeBits()) {4210 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
4211 // We have a pointer to a zero-bit value and we need to return4211 // We have a pointer to a zero-bit value and we need to return
4212 // a pointer to a zero-bit value.4212 // a pointer to a zero-bit value.
4213 return operand;4213 return operand;
...@@ -4231,7 +4231,7 @@ pub const FuncGen = struct {...@@ -4231,7 +4231,7 @@ pub const FuncGen = struct {
4231 var buf: Type.Payload.ElemType = undefined;4231 var buf: Type.Payload.ElemType = undefined;
4232 const payload_ty = optional_ty.optionalChild(&buf);4232 const payload_ty = optional_ty.optionalChild(&buf);
4233 const non_null_bit = self.context.intType(1).constAllOnes();4233 const non_null_bit = self.context.intType(1).constAllOnes();
4234 if (!payload_ty.hasRuntimeBits()) {4234 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
4235 // We have a pointer to a i1. We need to set it to 1 and then return the same pointer.4235 // We have a pointer to a i1. We need to set it to 1 and then return the same pointer.
4236 _ = self.builder.buildStore(non_null_bit, operand);4236 _ = self.builder.buildStore(non_null_bit, operand);
4237 return operand;4237 return operand;
...@@ -4268,7 +4268,7 @@ pub const FuncGen = struct {...@@ -4268,7 +4268,7 @@ pub const FuncGen = struct {
4268 const operand = try self.resolveInst(ty_op.operand);4268 const operand = try self.resolveInst(ty_op.operand);
4269 const optional_ty = self.air.typeOf(ty_op.operand);4269 const optional_ty = self.air.typeOf(ty_op.operand);
4270 const payload_ty = self.air.typeOfIndex(inst);4270 const payload_ty = self.air.typeOfIndex(inst);
4271 if (!payload_ty.hasRuntimeBits()) return null;4271 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) return null;
42724272
4273 if (optional_ty.isPtrLikeOptional()) {4273 if (optional_ty.isPtrLikeOptional()) {
4274 // Payload value is the same as the optional value.4274 // Payload value is the same as the optional value.
...@@ -4290,7 +4290,7 @@ pub const FuncGen = struct {...@@ -4290,7 +4290,7 @@ pub const FuncGen = struct {
4290 const result_ty = self.air.getRefType(ty_op.ty);4290 const result_ty = self.air.getRefType(ty_op.ty);
4291 const payload_ty = if (operand_is_ptr) result_ty.childType() else result_ty;4291 const payload_ty = if (operand_is_ptr) result_ty.childType() else result_ty;
42924292
4293 if (!payload_ty.hasRuntimeBits()) return null;4293 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) return null;
4294 if (operand_is_ptr or isByRef(payload_ty)) {4294 if (operand_is_ptr or isByRef(payload_ty)) {
4295 return self.builder.buildStructGEP(operand, 1, "");4295 return self.builder.buildStructGEP(operand, 1, "");
4296 }4296 }
...@@ -4311,7 +4311,7 @@ pub const FuncGen = struct {...@@ -4311,7 +4311,7 @@ pub const FuncGen = struct {
4311 const err_set_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty;4311 const err_set_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty;
43124312
4313 const payload_ty = err_set_ty.errorUnionPayload();4313 const payload_ty = err_set_ty.errorUnionPayload();
4314 if (!payload_ty.hasRuntimeBits()) {4314 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
4315 if (!operand_is_ptr) return operand;4315 if (!operand_is_ptr) return operand;
4316 return self.builder.buildLoad(operand, "");4316 return self.builder.buildLoad(operand, "");
4317 }4317 }
...@@ -4332,7 +4332,7 @@ pub const FuncGen = struct {...@@ -4332,7 +4332,7 @@ pub const FuncGen = struct {
4332 const error_ty = error_set_ty.errorUnionSet();4332 const error_ty = error_set_ty.errorUnionSet();
4333 const payload_ty = error_set_ty.errorUnionPayload();4333 const payload_ty = error_set_ty.errorUnionPayload();
4334 const non_error_val = try self.dg.genTypedValue(.{ .ty = error_ty, .val = Value.zero });4334 const non_error_val = try self.dg.genTypedValue(.{ .ty = error_ty, .val = Value.zero });
4335 if (!payload_ty.hasRuntimeBits()) {4335 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
4336 // We have a pointer to a i1. We need to set it to 1 and then return the same pointer.4336 // We have a pointer to a i1. We need to set it to 1 and then return the same pointer.
4337 _ = self.builder.buildStore(non_error_val, operand);4337 _ = self.builder.buildStore(non_error_val, operand);
4338 return operand;4338 return operand;
...@@ -4363,7 +4363,7 @@ pub const FuncGen = struct {...@@ -4363,7 +4363,7 @@ pub const FuncGen = struct {
4363 const ty_op = self.air.instructions.items(.data)[inst].ty_op;4363 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
4364 const payload_ty = self.air.typeOf(ty_op.operand);4364 const payload_ty = self.air.typeOf(ty_op.operand);
4365 const non_null_bit = self.context.intType(1).constAllOnes();4365 const non_null_bit = self.context.intType(1).constAllOnes();
4366 if (!payload_ty.hasRuntimeBits()) return non_null_bit;4366 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) return non_null_bit;
4367 const operand = try self.resolveInst(ty_op.operand);4367 const operand = try self.resolveInst(ty_op.operand);
4368 const optional_ty = self.air.typeOfIndex(inst);4368 const optional_ty = self.air.typeOfIndex(inst);
4369 if (optional_ty.isPtrLikeOptional()) return operand;4369 if (optional_ty.isPtrLikeOptional()) return operand;
...@@ -4391,7 +4391,7 @@ pub const FuncGen = struct {...@@ -4391,7 +4391,7 @@ pub const FuncGen = struct {
4391 const ty_op = self.air.instructions.items(.data)[inst].ty_op;4391 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
4392 const payload_ty = self.air.typeOf(ty_op.operand);4392 const payload_ty = self.air.typeOf(ty_op.operand);
4393 const operand = try self.resolveInst(ty_op.operand);4393 const operand = try self.resolveInst(ty_op.operand);
4394 if (!payload_ty.hasRuntimeBits()) {4394 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
4395 return operand;4395 return operand;
4396 }4396 }
4397 const inst_ty = self.air.typeOfIndex(inst);4397 const inst_ty = self.air.typeOfIndex(inst);
...@@ -4422,7 +4422,7 @@ pub const FuncGen = struct {...@@ -4422,7 +4422,7 @@ pub const FuncGen = struct {
4422 const err_un_ty = self.air.typeOfIndex(inst);4422 const err_un_ty = self.air.typeOfIndex(inst);
4423 const payload_ty = err_un_ty.errorUnionPayload();4423 const payload_ty = err_un_ty.errorUnionPayload();
4424 const operand = try self.resolveInst(ty_op.operand);4424 const operand = try self.resolveInst(ty_op.operand);
4425 if (!payload_ty.hasRuntimeBits()) {4425 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
4426 return operand;4426 return operand;
4427 }4427 }
4428 const err_un_llvm_ty = try self.dg.llvmType(err_un_ty);4428 const err_un_llvm_ty = try self.dg.llvmType(err_un_ty);
...@@ -5235,7 +5235,7 @@ pub const FuncGen = struct {...@@ -5235,7 +5235,7 @@ pub const FuncGen = struct {
5235 const fn_info = self.dg.decl.ty.fnInfo();5235 const fn_info = self.dg.decl.ty.fnInfo();
5236 var i: u32 = 0;5236 var i: u32 = 0;
5237 for (fn_info.param_types) |param_ty, src_index| {5237 for (fn_info.param_types) |param_ty, src_index| {
5238 if (!param_ty.hasRuntimeBits()) continue;5238 if (!param_ty.hasRuntimeBitsIgnoreComptime()) continue;
5239 if (i == runtime_index) return @intCast(u32, src_index);5239 if (i == runtime_index) return @intCast(u32, src_index);
5240 i += 1;5240 i += 1;
5241 } else unreachable;5241 } else unreachable;
...@@ -6021,7 +6021,7 @@ pub const FuncGen = struct {...@@ -6021,7 +6021,7 @@ pub const FuncGen = struct {
60216021
6022 const llvm_union_ty = t: {6022 const llvm_union_ty = t: {
6023 const payload = p: {6023 const payload = p: {
6024 if (!field.ty.hasRuntimeBits()) {6024 if (!field.ty.hasRuntimeBitsIgnoreComptime()) {
6025 const padding_len = @intCast(c_uint, layout.payload_size);6025 const padding_len = @intCast(c_uint, layout.payload_size);
6026 break :p self.context.intType(8).arrayType(padding_len);6026 break :p self.context.intType(8).arrayType(padding_len);
6027 }6027 }
...@@ -6377,7 +6377,7 @@ pub const FuncGen = struct {...@@ -6377,7 +6377,7 @@ pub const FuncGen = struct {
6377 const union_obj = union_ty.cast(Type.Payload.Union).?.data;6377 const union_obj = union_ty.cast(Type.Payload.Union).?.data;
6378 const field = &union_obj.fields.values()[field_index];6378 const field = &union_obj.fields.values()[field_index];
6379 const result_llvm_ty = try self.dg.llvmType(self.air.typeOfIndex(inst));6379 const result_llvm_ty = try self.dg.llvmType(self.air.typeOfIndex(inst));
6380 if (!field.ty.hasRuntimeBits()) {6380 if (!field.ty.hasRuntimeBitsIgnoreComptime()) {
6381 return null;6381 return null;
6382 }6382 }
6383 const target = self.dg.module.getTarget();6383 const target = self.dg.module.getTarget();
...@@ -6811,7 +6811,7 @@ fn llvmFieldIndex(...@@ -6811,7 +6811,7 @@ fn llvmFieldIndex(
68116811
6812 var llvm_field_index: c_uint = 0;6812 var llvm_field_index: c_uint = 0;
6813 for (ty.structFields().values()) |field, i| {6813 for (ty.structFields().values()) |field, i| {
6814 if (field.is_comptime or !field.ty.hasRuntimeBits()) continue;6814 if (field.is_comptime or !field.ty.hasRuntimeBitsIgnoreComptime()) continue;
68156815
6816 const field_align = field.normalAlignment(target);6816 const field_align = field.normalAlignment(target);
6817 big_align = @maximum(big_align, field_align);6817 big_align = @maximum(big_align, field_align);
...@@ -6887,7 +6887,7 @@ fn isByRef(ty: Type) bool {...@@ -6887,7 +6887,7 @@ fn isByRef(ty: Type) bool {
6887 .AnyFrame,6887 .AnyFrame,
6888 => return false,6888 => return false,
68896889
6890 .Array, .Frame => return ty.hasRuntimeBits(),6890 .Array, .Frame => return ty.hasRuntimeBitsIgnoreComptime(),
6891 .Struct => {6891 .Struct => {
6892 // Packed structs are represented to LLVM as integers.6892 // Packed structs are represented to LLVM as integers.
6893 if (ty.containerLayout() == .Packed) return false;6893 if (ty.containerLayout() == .Packed) return false;
...@@ -6906,7 +6906,7 @@ fn isByRef(ty: Type) bool {...@@ -6906,7 +6906,7 @@ fn isByRef(ty: Type) bool {
6906 var count: usize = 0;6906 var count: usize = 0;
6907 const fields = ty.structFields();6907 const fields = ty.structFields();
6908 for (fields.values()) |field| {6908 for (fields.values()) |field| {
6909 if (field.is_comptime or !field.ty.hasRuntimeBits()) continue;6909 if (field.is_comptime or !field.ty.hasRuntimeBitsIgnoreComptime()) continue;
69106910
6911 count += 1;6911 count += 1;
6912 if (count > max_fields_byval) return true;6912 if (count > max_fields_byval) return true;
...@@ -6914,7 +6914,7 @@ fn isByRef(ty: Type) bool {...@@ -6914,7 +6914,7 @@ fn isByRef(ty: Type) bool {
6914 }6914 }
6915 return false;6915 return false;
6916 },6916 },
6917 .Union => return ty.hasRuntimeBits(),6917 .Union => return ty.hasRuntimeBitsIgnoreComptime(),
6918 .ErrorUnion => return isByRef(ty.errorUnionPayload()),6918 .ErrorUnion => return isByRef(ty.errorUnionPayload()),
6919 .Optional => {6919 .Optional => {
6920 var buf: Type.Payload.ElemType = undefined;6920 var buf: Type.Payload.ElemType = undefined;