diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-10-11 15:50:39 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-10-11 15:50:39 -0700 |
| commit | 5af7ae1dc45a4adafe72a91c1f849d599a6ff3eb (patch) | |
| tree | edd4dcc8e5cf39fb9d9c85096c9f21b559751172 /src | |
| parent | 6d6cf598475ab8d2c3259002655ba04f1d056b2e (diff) | |
| download | zig-5af7ae1dc45a4adafe72a91c1f849d599a6ff3eb.tar.gz zig-5af7ae1dc45a4adafe72a91c1f849d599a6ff3eb.zip | |
stage2: LLVM backend: fix var args function calls
Diffstat (limited to 'src')
| -rw-r--r-- | src/Air.zig | 8 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 14 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/Air.zig b/src/Air.zig index 4d3fea13f3..9ad8bc9ae4 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -264,10 +264,10 @@ pub const Inst = struct { /// Uses the `un_op` field. /// Triggers `resolveTypeLayout` on the return type. ret, - /// This instruction communicates that the function's result value is inside - /// the operand, which is a pointer. If the function will pass the result by-ref, - /// the pointer operand is a `ret_ptr` instruction. Otherwise, this instruction - /// is equivalent to a `load` on the operand, followed by a `ret` on the loaded value. + /// This instruction communicates that the function's result value is pointed to by + /// the operand. If the function will pass the result by-ref, the operand is a + /// `ret_ptr` instruction. Otherwise, this instruction is equivalent to a `load` + /// on the operand, followed by a `ret` on the loaded value. /// Result type is always noreturn; no instructions in a block follow this one. /// Uses the `un_op` field. /// Triggers `resolveTypeLayout` on the return type. diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index b76a136d6f..458ab093e4 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1490,11 +1490,17 @@ pub const FuncGen = struct { break :blk ret_ptr; }; - for (args) |arg, i| { - const param_ty = fn_info.param_types[i]; - if (!param_ty.hasCodeGenBits()) continue; + if (fn_info.is_var_args) { + for (args) |arg| { + try llvm_args.append(try self.resolveInst(arg)); + } + } else { + for (args) |arg, i| { + const param_ty = fn_info.param_types[i]; + if (!param_ty.hasCodeGenBits()) continue; - try llvm_args.append(try self.resolveInst(arg)); + try llvm_args.append(try self.resolveInst(arg)); + } } const call = self.builder.buildCall( |
