authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-11 15:50:39-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-11 15:50:39-07:00
log5af7ae1dc45a4adafe72a91c1f849d599a6ff3eb
treeedd4dcc8e5cf39fb9d9c85096c9f21b559751172
parent6d6cf598475ab8d2c3259002655ba04f1d056b2e

stage2: LLVM backend: fix var args function calls


2 files changed, 14 insertions(+), 8 deletions(-)

src/Air.zig+4-4
......@@ -264,10 +264,10 @@ pub const Inst = struct {
264264 /// Uses the `un_op` field.
265265 /// Triggers `resolveTypeLayout` on the return type.
266266 ret,
267 /// This instruction communicates that the function's result value is inside
268 /// the operand, which is a pointer. If the function will pass the result by-ref,
269 /// the pointer operand is a `ret_ptr` instruction. Otherwise, this instruction
270 /// is equivalent to a `load` on the operand, followed by a `ret` on the loaded value.
267 /// This instruction communicates that the function's result value is pointed to by
268 /// the operand. If the function will pass the result by-ref, the operand is a
269 /// `ret_ptr` instruction. Otherwise, this instruction is equivalent to a `load`
270 /// on the operand, followed by a `ret` on the loaded value.
271271 /// Result type is always noreturn; no instructions in a block follow this one.
272272 /// Uses the `un_op` field.
273273 /// Triggers `resolveTypeLayout` on the return type.
src/codegen/llvm.zig+10-4
......@@ -1490,11 +1490,17 @@ pub const FuncGen = struct {
14901490 break :blk ret_ptr;
14911491 };
14921492
1493 for (args) |arg, i| {
1494 const param_ty = fn_info.param_types[i];
1495 if (!param_ty.hasCodeGenBits()) continue;
1493 if (fn_info.is_var_args) {
1494 for (args) |arg| {
1495 try llvm_args.append(try self.resolveInst(arg));
1496 }
1497 } else {
1498 for (args) |arg, i| {
1499 const param_ty = fn_info.param_types[i];
1500 if (!param_ty.hasCodeGenBits()) continue;
14961501
1497 try llvm_args.append(try self.resolveInst(arg));
1502 try llvm_args.append(try self.resolveInst(arg));
1503 }
14981504 }
14991505
15001506 const call = self.builder.buildCall(