Skip to content

Commit

Permalink
x86_64,riscv64: fix incorrect incoming_stack_alignment handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mlugg committed Oct 16, 2024
1 parent f4b97ee commit 183570c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/Zcu.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3575,7 +3575,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) {
Expand Down
5 changes: 1 addition & 4 deletions src/arch/riscv64/CodeGen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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, .aligment = .@"1" }),
);
function.frame_allocs.set(
@intFromEnum(FrameIndex.call_frame),
Expand Down
5 changes: 1 addition & 4 deletions src/arch/x86_64/CodeGen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 183570c

Please sign in to comment.