| ... | @@ -1242,14 +1242,19 @@ const DeclGen = struct { | ... | @@ -1242,14 +1242,19 @@ const DeclGen = struct { |
| 1242 | | 1242 | |
| 1243 | const param_ty_refs = try self.gpa.alloc(CacheRef, fn_info.param_types.len); | 1243 | const param_ty_refs = try self.gpa.alloc(CacheRef, fn_info.param_types.len); |
| 1244 | defer self.gpa.free(param_ty_refs); | 1244 | defer self.gpa.free(param_ty_refs); |
| 1245 | for (param_ty_refs, fn_info.param_types.get(ip)) |*param_type, fn_param_type| { | 1245 | var param_index: usize = 0; |
| 1246 | param_type.* = try self.resolveType(fn_param_type.toType(), .direct); | 1246 | for (fn_info.param_types.get(ip)) |param_ty_index| { |
| | 1247 | const param_ty = param_ty_index.toType(); |
| | 1248 | if (!param_ty.hasRuntimeBitsIgnoreComptime(mod)) continue; |
| | 1249 | |
| | 1250 | param_ty_refs[param_index] = try self.resolveType(param_ty, .direct); |
| | 1251 | param_index += 1; |
| 1247 | } | 1252 | } |
| 1248 | const return_ty_ref = try self.resolveType(fn_info.return_type.toType(), .direct); | 1253 | const return_ty_ref = try self.resolveType(fn_info.return_type.toType(), .direct); |
| 1249 | | 1254 | |
| 1250 | const ty_ref = try self.spv.resolve(.{ .function_type = .{ | 1255 | const ty_ref = try self.spv.resolve(.{ .function_type = .{ |
| 1251 | .return_type = return_ty_ref, | 1256 | .return_type = return_ty_ref, |
| 1252 | .parameters = param_ty_refs, | 1257 | .parameters = param_ty_refs[0..param_index], |
| 1253 | } }); | 1258 | } }); |
| 1254 | | 1259 | |
| 1255 | try self.type_map.put(self.gpa, ty.toIntern(), .{ .ty_ref = ty_ref }); | 1260 | try self.type_map.put(self.gpa, ty.toIntern(), .{ .ty_ref = ty_ref }); |
| ... | @@ -1675,9 +1680,11 @@ const DeclGen = struct { | ... | @@ -1675,9 +1680,11 @@ const DeclGen = struct { |
| 1675 | const fn_info = mod.typeToFunc(decl.ty).?; | 1680 | const fn_info = mod.typeToFunc(decl.ty).?; |
| 1676 | | 1681 | |
| 1677 | try self.args.ensureUnusedCapacity(self.gpa, fn_info.param_types.len); | 1682 | try self.args.ensureUnusedCapacity(self.gpa, fn_info.param_types.len); |
| 1678 | for (0..fn_info.param_types.len) |i| { | 1683 | for (fn_info.param_types.get(ip)) |param_ty_index| { |
| 1679 | const param_type = fn_info.param_types.get(ip)[i]; | 1684 | const param_ty = param_ty_index.toType(); |
| 1680 | const param_type_id = try self.resolveTypeId(param_type.toType()); | 1685 | if (!param_ty.hasRuntimeBitsIgnoreComptime(mod)) continue; |
| | 1686 | |
| | 1687 | const param_type_id = try self.resolveTypeId(param_ty); |
| 1681 | const arg_result_id = self.spv.allocId(); | 1688 | const arg_result_id = self.spv.allocId(); |
| 1682 | try self.func.prologue.emit(self.spv.gpa, .OpFunctionParameter, .{ | 1689 | try self.func.prologue.emit(self.spv.gpa, .OpFunctionParameter, .{ |
| 1683 | .id_result_type = param_type_id, | 1690 | .id_result_type = param_type_id, |
| ... | @@ -3986,9 +3993,9 @@ const DeclGen = struct { | ... | @@ -3986,9 +3993,9 @@ const DeclGen = struct { |
| 3986 | // Note: resolve() might emit instructions, so we need to call it | 3993 | // Note: resolve() might emit instructions, so we need to call it |
| 3987 | // before starting to emit OpFunctionCall instructions. Hence the | 3994 | // before starting to emit OpFunctionCall instructions. Hence the |
| 3988 | // temporary params buffer. | 3995 | // temporary params buffer. |
| 3989 | const arg_id = try self.resolve(arg); | | |
| 3990 | const arg_ty = self.typeOf(arg); | 3996 | const arg_ty = self.typeOf(arg); |
| 3991 | if (!arg_ty.hasRuntimeBitsIgnoreComptime(mod)) continue; | 3997 | if (!arg_ty.hasRuntimeBitsIgnoreComptime(mod)) continue; |
| | 3998 | const arg_id = try self.resolve(arg); |
| 3992 | | 3999 | |
| 3993 | params[n_params] = arg_id; | 4000 | params[n_params] = arg_id; |
| 3994 | n_params += 1; | 4001 | n_params += 1; |