Meta
Checked on rustc 1.12.0 with MIR on, 1.15.1, 1.16 and 1.18. Does not affect 1.12.0 with MIR off.
STR
#![crate_type="rlib"]
pub struct Big {
drop_me: [Option<Box<u8>>; 64],
}
pub fn supersize_me(meal: fn() -> Big, out: &mut Vec<Big>) {
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal());
out.push(meal()); // 16 calls to `push`
}
Expected Result
Function should use a small amount of stack space, definitely less than 2 kilobytes (Big is 512 bytes per copy); 1.12.0 with -Z orbit=off uses 1088 bytes of stack.
Actual Result
When compiled, the function uses more than 16384 = 8*64*16*2 bytes of stack space, as is evident from subq $16384, %rsp in the assembly - 2 copies of Big for every call to push.
Notes
This is the root cause for #40573. It is not new, however - it was probably always present in MIR.
Meta
Checked on rustc 1.12.0 with MIR on, 1.15.1, 1.16 and 1.18. Does not affect 1.12.0 with MIR off.
STR
Expected Result
Function should use a small amount of stack space, definitely less than 2 kilobytes (
Bigis 512 bytes per copy); 1.12.0 with-Z orbit=offuses 1088 bytes of stack.Actual Result
When compiled, the function uses more than
16384 = 8*64*16*2bytes of stack space, as is evident fromsubq $16384, %rspin the assembly - 2 copies ofBigfor every call topush.Notes
This is the root cause for #40573. It is not new, however - it was probably always present in MIR.