| ... | ... | @@ -687,9 +687,6 @@ pub const DeclGen = struct { |
| 687 | 687 | const target = dg.module.getTarget(); |
| 688 | 688 | const sret = firstParamSRet(fn_info, target); |
| 689 | 689 | |
| 690 | | const return_type = fn_info.return_type; |
| 691 | | const raw_llvm_ret_ty = try dg.llvmType(return_type); |
| 692 | | |
| 693 | 690 | const fn_type = try dg.llvmType(zig_fn_type); |
| 694 | 691 | |
| 695 | 692 | const fqn = try decl.getFullyQualifiedName(dg.gpa); |
| ... | ... | @@ -708,6 +705,8 @@ pub const DeclGen = struct { |
| 708 | 705 | if (sret) { |
| 709 | 706 | dg.addArgAttr(llvm_fn, 0, "nonnull"); // Sret pointers must not be address 0 |
| 710 | 707 | dg.addArgAttr(llvm_fn, 0, "noalias"); |
| 708 | |
| 709 | const raw_llvm_ret_ty = try dg.llvmType(fn_info.return_type); |
| 711 | 710 | llvm_fn.addSretAttr(0, raw_llvm_ret_ty); |
| 712 | 711 | } |
| 713 | 712 | |
| ... | ... | @@ -737,7 +736,7 @@ pub const DeclGen = struct { |
| 737 | 736 | // Function attributes that are independent of analysis results of the function body. |
| 738 | 737 | dg.addCommonFnAttributes(llvm_fn); |
| 739 | 738 | |
| 740 | | if (return_type.isNoReturn()) { |
| 739 | if (fn_info.return_type.isNoReturn()) { |
| 741 | 740 | dg.addFnAttr(llvm_fn, "noreturn"); |
| 742 | 741 | } |
| 743 | 742 | |
| ... | ... | @@ -829,6 +828,7 @@ pub const DeclGen = struct { |
| 829 | 828 | .Void, .NoReturn => return dg.context.voidType(), |
| 830 | 829 | .Int => { |
| 831 | 830 | const info = t.intInfo(target); |
| 831 | assert(info.bits != 0); |
| 832 | 832 | return dg.context.intType(info.bits); |
| 833 | 833 | }, |
| 834 | 834 | .Enum => { |
| ... | ... | @@ -1147,17 +1147,17 @@ pub const DeclGen = struct { |
| 1147 | 1147 | const fn_info = t.fnInfo(); |
| 1148 | 1148 | const sret = firstParamSRet(fn_info, target); |
| 1149 | 1149 | const return_type = fn_info.return_type; |
| 1150 | | const raw_llvm_ret_ty = try dg.llvmType(return_type); |
| 1151 | | const llvm_ret_ty = if (!return_type.hasRuntimeBits() or sret) |
| 1152 | | dg.context.voidType() |
| 1150 | const llvm_sret_ty = if (return_type.hasRuntimeBits()) |
| 1151 | try dg.llvmType(return_type) |
| 1153 | 1152 | else |
| 1154 | | raw_llvm_ret_ty; |
| 1153 | dg.context.voidType(); |
| 1154 | const llvm_ret_ty = if (sret) dg.context.voidType() else llvm_sret_ty; |
| 1155 | 1155 | |
| 1156 | 1156 | var llvm_params = std.ArrayList(*const llvm.Type).init(dg.gpa); |
| 1157 | 1157 | defer llvm_params.deinit(); |
| 1158 | 1158 | |
| 1159 | 1159 | if (sret) { |
| 1160 | | try llvm_params.append(raw_llvm_ret_ty.pointerType(0)); |
| 1160 | try llvm_params.append(llvm_sret_ty.pointerType(0)); |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | for (fn_info.param_types) |param_ty| { |
| ... | ... | @@ -1210,6 +1210,7 @@ pub const DeclGen = struct { |
| 1210 | 1210 | const bigint = tv.val.toBigInt(&bigint_space); |
| 1211 | 1211 | const target = dg.module.getTarget(); |
| 1212 | 1212 | const int_info = tv.ty.intInfo(target); |
| 1213 | assert(int_info.bits != 0); |
| 1213 | 1214 | const llvm_type = dg.context.intType(int_info.bits); |
| 1214 | 1215 | |
| 1215 | 1216 | const unsigned_val = v: { |
| ... | ... | @@ -2241,7 +2242,6 @@ pub const FuncGen = struct { |
| 2241 | 2242 | }; |
| 2242 | 2243 | const fn_info = zig_fn_ty.fnInfo(); |
| 2243 | 2244 | const return_type = fn_info.return_type; |
| 2244 | | const llvm_ret_ty = try self.dg.llvmType(return_type); |
| 2245 | 2245 | const llvm_fn = try self.resolveInst(pl_op.operand); |
| 2246 | 2246 | const target = self.dg.module.getTarget(); |
| 2247 | 2247 | const sret = firstParamSRet(fn_info, target); |
| ... | ... | @@ -2250,6 +2250,7 @@ pub const FuncGen = struct { |
| 2250 | 2250 | defer llvm_args.deinit(); |
| 2251 | 2251 | |
| 2252 | 2252 | const ret_ptr = if (!sret) null else blk: { |
| 2253 | const llvm_ret_ty = try self.dg.llvmType(return_type); |
| 2253 | 2254 | const ret_ptr = self.buildAlloca(llvm_ret_ty); |
| 2254 | 2255 | ret_ptr.setAlignment(return_type.abiAlignment(target)); |
| 2255 | 2256 | try llvm_args.append(ret_ptr); |
| ... | ... | @@ -2284,6 +2285,7 @@ pub const FuncGen = struct { |
| 2284 | 2285 | } else if (self.liveness.isUnused(inst) or !return_type.hasRuntimeBits()) { |
| 2285 | 2286 | return null; |
| 2286 | 2287 | } else if (sret) { |
| 2288 | const llvm_ret_ty = try self.dg.llvmType(return_type); |
| 2287 | 2289 | call.setCallSret(llvm_ret_ty); |
| 2288 | 2290 | return ret_ptr; |
| 2289 | 2291 | } else { |