Skip to content

Commit 28f3d6f

Browse files
committed
Pass big aggregated arguments indirectly.
Ensures that arguments of any type can be passed through `classify_arg_ty()`. Previously any aggregated argument with a size above the maximum of `MAX_ARG_IN_REGS_SIZE` triggered the `stack_required` assertion. The reason was that that the flag directly depends on the calculated amount of required registered which is not determined if a given argument is bigger than the expected maximum of `MAX_ARG_IN_REGS_SIZE`.
1 parent 1f53815 commit 28f3d6f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/librustc_target/abi/call/xtensa.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>, xlen: u64, remaining_gpr: &mut
2020
// according to the ABI. 2*XLen-aligned varargs are passed in "aligned"
2121
// register pairs, so may consume 3 registers.
2222

23-
let mut stack_required = false;
2423
let arg_size = arg.layout.size;
25-
let alignment = arg.layout.details.align.abi;
26-
24+
if arg_size.bits() > MAX_ARG_IN_REGS_SIZE {
25+
arg.make_indirect();
26+
return;
27+
}
2728

29+
let alignment = arg.layout.details.align.abi;
2830
let mut required_gpr = 1u64; // at least one per arg
31+
2932
if alignment.bits() == 2 * xlen {
3033
required_gpr = 2 + (*remaining_gpr % 2);
3134
} else if arg_size.bits() > xlen && arg_size.bits() <= MAX_ARG_IN_REGS_SIZE {
3235
required_gpr = (arg_size.bits() + (xlen - 1)) / xlen;
3336
}
3437

38+
let mut stack_required = false;
3539
if required_gpr > *remaining_gpr {
3640
stack_required = true;
3741
required_gpr = *remaining_gpr;

0 commit comments

Comments
 (0)