|
| 1 | +//@ revisions: enable-backchain disable-backchain |
| 2 | +//@ assembly-output: emit-asm |
| 3 | +//@ compile-flags: -O --crate-type=lib --target=s390x-unknown-linux-gnu |
| 4 | +//@ needs-llvm-components: systemz |
| 5 | +//@[enable-backchain] compile-flags: -Ctarget-feature=+backchain |
| 6 | +//@[disable-backchain] compile-flags: -Ctarget-feature=-backchain |
| 7 | +#![feature(no_core, lang_items)] |
| 8 | +#![no_std] |
| 9 | +#![no_core] |
| 10 | + |
| 11 | +#[lang = "sized"] |
| 12 | +trait Sized {} |
| 13 | + |
| 14 | +extern "C" { |
| 15 | + fn extern_func(); |
| 16 | +} |
| 17 | + |
| 18 | +// CHECK-LABEL: test_backchain |
| 19 | +#[no_mangle] |
| 20 | +extern "C" fn test_backchain() -> i32 { |
| 21 | + // Here we try to match if backchain register is saved to the parameter area (stored in r15/sp) |
| 22 | + // And also if a new parameter area (160 bytes) is allocated for the upcoming function call |
| 23 | + // enable-backchain: lgr [[REG1:.*]], %r15 |
| 24 | + // enable-backchain-NEXT: aghi %r15, -160 |
| 25 | + // enable-backchain: stg [[REG1]], 0(%r15) |
| 26 | + // disable-backchain: aghi %r15, -160 |
| 27 | + // disable-backchain-NOT: stg %r{{.*}}, 0(%r15) |
| 28 | + unsafe { |
| 29 | + extern_func(); |
| 30 | + } |
| 31 | + // enable-backchain-NEXT: brasl %r{{.*}}, extern_func@PLT |
| 32 | + // disable-backchain: brasl %r{{.*}}, extern_func@PLT |
| 33 | + |
| 34 | + // Make sure that the expected return value is written into %r2 (return register): |
| 35 | + // enable-backchain-NEXT: lghi %r2, 1 |
| 36 | + // disable-backchain: lghi %r2, 0 |
| 37 | + #[cfg(target_feature = "backchain")] |
| 38 | + { |
| 39 | + 1 |
| 40 | + } |
| 41 | + #[cfg(not(target_feature = "backchain"))] |
| 42 | + { |
| 43 | + 0 |
| 44 | + } |
| 45 | + // CHECK: br %r{{.*}} |
| 46 | +} |
0 commit comments