commit 387965a696e567357ca4729b41951e51592ef821 (tree)
parent cf39652500df07d33470d89ba96a97463beff986
Author: mlugg <mlugg@mlugg.co.uk>
Date: Wed, 16 Oct 2024 17:19:40 +0100
x86_64,riscv64: fix incorrect `incoming_stack_alignment` handling
The whole motivation behind this proposal in the first place was that
the LLVM backend disagrees with the self-hosted backends on what
`@setAlignStack` meant, so we can't just translate the old logic to the
new system! These backends can introduce support for overriding
`incoming_stack_alignment` later on.
Diffstat:
3 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/Zcu.zig b/src/Zcu.zig
@@ -3607,7 +3607,8 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
else => false,
},
.stage2_x86_64 => switch (cc) {
- .x86_64_sysv, .x86_64_win, .naked => true, // stack alignment supported
+ .x86_64_sysv, .x86_64_win => |opts| opts.incoming_stack_alignment == null,
+ .naked => true,
else => false,
},
.stage2_aarch64 => switch (cc) {
diff --git a/src/arch/riscv64/CodeGen.zig b/src/arch/riscv64/CodeGen.zig
@@ -820,10 +820,7 @@ pub fn generate(
try function.frame_allocs.resize(gpa, FrameIndex.named_count);
function.frame_allocs.set(
@intFromEnum(FrameIndex.stack_frame),
- FrameAlloc.init(.{
- .size = 0,
- .alignment = .fromByteUnits(target_util.stackAlignment(function.target.*, fn_type.fnCallingConvention(zcu))),
- }),
+ FrameAlloc.init(.{ .size = 0, .alignment = .@"1" }),
);
function.frame_allocs.set(
@intFromEnum(FrameIndex.call_frame),
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig
@@ -871,10 +871,7 @@ pub fn generate(
try function.frame_allocs.resize(gpa, FrameIndex.named_count);
function.frame_allocs.set(
@intFromEnum(FrameIndex.stack_frame),
- FrameAlloc.init(.{
- .size = 0,
- .alignment = .fromByteUnits(target_util.stackAlignment(function.target.*, fn_type.fnCallingConvention(zcu))),
- }),
+ FrameAlloc.init(.{ .size = 0, .alignment = .@"1" }),
);
function.frame_allocs.set(
@intFromEnum(FrameIndex.call_frame),