Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s390x: Fix a regression related to backchain feature #129940

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,7 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
None
}
})
.filter(|feature| {
RUSTC_SPECIAL_FEATURES.contains(feature) || features.contains(&Symbol::intern(feature))
})
.filter(|feature| features.contains(&Symbol::intern(feature)))
.map(|feature| Symbol::intern(feature))
.collect()
}
Expand Down
46 changes: 46 additions & 0 deletions tests/assembly/s390x-backchain-toggle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//@ revisions: enable-backchain disable-backchain
//@ assembly-output: emit-asm
//@ compile-flags: -O --crate-type=lib --target=s390x-unknown-linux-gnu
//@ needs-llvm-components: systemz
//@[enable-backchain] compile-flags: -Ctarget-feature=+backchain
//@[disable-backchain] compile-flags: -Ctarget-feature=-backchain
#![feature(no_core, lang_items)]
#![no_std]
#![no_core]

#[lang = "sized"]
trait Sized {}

extern "C" {
fn extern_func();
}

// CHECK-LABEL: test_backchain
#[no_mangle]
extern "C" fn test_backchain() -> i32 {
// Here we try to match if backchain register is saved to the parameter area (stored in r15/sp)
// And also if a new parameter area (160 bytes) is allocated for the upcoming function call
// enable-backchain: lgr [[REG1:.*]], %r15
// enable-backchain-NEXT: aghi %r15, -160
// enable-backchain: stg [[REG1]], 0(%r15)
// disable-backchain: aghi %r15, -160
// disable-backchain-NOT: stg %r{{.*}}, 0(%r15)
unsafe {
extern_func();
}
// enable-backchain-NEXT: brasl %r{{.*}}, extern_func@PLT
liushuyu marked this conversation as resolved.
Show resolved Hide resolved
// disable-backchain: brasl %r{{.*}}, extern_func@PLT

// Make sure that the expected return value is written into %r2 (return register):
// enable-backchain-NEXT: lghi %r2, 1
liushuyu marked this conversation as resolved.
Show resolved Hide resolved
// disable-backchain: lghi %r2, 0
RalfJung marked this conversation as resolved.
Show resolved Hide resolved
#[cfg(target_feature = "backchain")]
{
1
}
#[cfg(not(target_feature = "backchain"))]
{
0
}
RalfJung marked this conversation as resolved.
Show resolved Hide resolved
// CHECK: br %r{{.*}}
}
Loading