commit a7da90071e23f22158ef508a263cb3a4054554dd (tree)
parent 29928af6005997d2b02b4c3a3576a696a02fa269
Author: joachimschmidt557 <joachim.schmidt557@outlook.com>
Date: Fri, 8 Jan 2021 22:11:49 +0100
stage2: fix bug in genArg
When an argument is unused in the function body, still increment
arg_index so we still select the correct arguments in the args slice.
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/codegen.zig b/src/codegen.zig
@@ -1480,6 +1480,9 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
}
fn genArg(self: *Self, inst: *ir.Inst.Arg) !MCValue {
+ const arg_index = self.arg_index;
+ self.arg_index += 1;
+
if (FreeRegInt == u0) {
return self.fail(inst.base.src, "TODO implement Register enum for {}", .{self.target.cpu.arch});
}
@@ -1488,8 +1491,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
try self.registers.ensureCapacity(self.gpa, self.registers.count() + 1);
- const result = self.args[self.arg_index];
- self.arg_index += 1;
+ const result = self.args[arg_index];
const name_with_null = inst.name[0 .. mem.lenZ(inst.name) + 1];
switch (result) {