38_tail_stack_fallback.toy (600B)
1 fn many(a: i64, b: i64, c: i64, d: i64, e: i64, 2 f: i64, g: i64, h: i64, i: i64, j: i64): i64 { 3 return a; 4 } 5 6 // `caller` takes one parameter (no incoming stack-arg area), but `many` needs 7 // stack arguments (10 ints exceed the 8 argument registers). The sibling call 8 // cannot reuse the caller's parameter area, so this ALLOWED tail is not 9 // realizable and CG falls back to an ordinary call + return. Result is `a`. 10 fn caller(x: i64): i64 { 11 return tail many(x, 0, 0, 0, 0, 0, 0, 0, 0, 0); 12 } 13 14 fn __user_main(): i64 { 15 return caller(42); 16 } 17 18 fn main(): i32 { return __user_main() as i32; }