| 537 | |
| 538 | // A nine-arg callee exercises the stack-passed argument path (caller_sp), |
| 539 | // which is the one place omitting the frame pointer changes the base register. |
| 540 | const OMIT_FP_PROGRAM: &str = r#" |
| 541 | sum9: (a: i64, b: i64, c: i64, d: i64, e: i64, f: i64, g: i64, h: i64, i: i64) -> i64 { |
| 542 | return a + b + c + d + e + f + g + h + i |
| 543 | } |
| 544 | |
| 545 | main: () -> i32 { |
| 546 | total: i64 = sum9(1, 2, 3, 4, 5, 6, 7, 8, 9) |
| 547 | return total as i32 |
| 548 | } |
| 549 | "#; |
| 550 | |
| 551 | #[test] |
| 552 | fn omit_frame_pointer_preserves_behavior() { |
| 553 | let (base_outcome, base_uart, base_lines) = run_hll_omit_fp(OMIT_FP_PROGRAM, false); |
| 554 | let (omit_outcome, omit_uart, omit_lines) = run_hll_omit_fp(OMIT_FP_PROGRAM, true); |
| 555 | |
| 556 | assert_eq!( |
| 557 | format!("{base_outcome:?}"), |
| 558 | format!("{omit_outcome:?}"), |
| 559 | "omitting the frame pointer changed the exit outcome" |
| 560 | ); |
| 561 | assert_eq!( |
| 562 | base_uart, omit_uart, |
| 563 | "omitting the frame pointer changed UART output" |
| 564 | ); |
| 565 | assert!( |