diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-01-19 18:59:46 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-01-19 20:21:05 +0100 |
| commit | 7c831cc2663ba4e0ce2cf29ca4a3bd9a4a074f5c (patch) | |
| tree | 02bea370f0f6220f0ab02c04935a2208a2b3d97f /src | |
| parent | df6c0067b26ca1b6798612631b26b167e9fe287a (diff) | |
| download | zig-7c831cc2663ba4e0ce2cf29ca4a3bd9a4a074f5c.tar.gz zig-7c831cc2663ba4e0ce2cf29ca4a3bd9a4a074f5c.zip | |
stage2: add tweak to please Apple re stack alignment
This is more like a temp hack than anything else - I think the
mechanism we use for adjusting the stack when pushing args onto
the stack could/should be reused - i.e., we should just calculate
the stack alignment before each call and then reset the `rsp`
rather than relying on the current hack in `gen()` logic.
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/x86_64/CodeGen.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 62983c5b80..522da6e25d 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -512,9 +512,11 @@ fn gen(self: *Self) InnerError!void { }); } while (self.stack_args_relocs.popOrNull()) |index| { + // TODO like above, gotta figure out the alignment shenanigans for macOS, etc. + const adjustment = if (self.target.isDarwin()) 2 * stack_adjustment else stack_adjustment; // +16 bytes to account for saved return address of the `call` instruction and // `push rbp`. - self.mir_instructions.items(.data)[index].imm += stack_adjustment + aligned_stack_end + 16; + self.mir_instructions.items(.data)[index].imm += adjustment + aligned_stack_end + 16; } } else { _ = try self.addInst(.{ |
