Skip to content

Mark condition/carry bit as clobbered in C-SKY inline assembly #136217

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

Merged
merged 1 commit into from
Feb 13, 2025
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: 3 additions & 1 deletion compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
InlineAsmArch::M68k => {
constraints.push("~{ccr}".to_string());
}
InlineAsmArch::CSKY => {}
InlineAsmArch::CSKY => {
constraints.push("~{psr}".to_string());
}
}
}
if !options.contains(InlineAsmOptions::NOMEM) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,5 @@ These flags registers must be restored upon exiting the asm block if the `preser
- SPARC
- Integer condition codes (`icc` and `xcc`)
- Floating-point condition codes (`fcc[0-3]`)
- CSKY
- Condition/carry bit (C) in `PSR`.
24 changes: 24 additions & 0 deletions tests/codegen/asm/csky-clobbers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ add-core-stubs
//@ compile-flags: --target csky-unknown-linux-gnuabiv2
//@ needs-llvm-components: csky

#![crate_type = "rlib"]
#![feature(no_core, asm_experimental_arch)]
#![no_core]

extern crate minicore;
use minicore::*;

// CHECK-LABEL: @flags_clobber
// CHECK: call void asm sideeffect "", "~{psr}"()
#[no_mangle]
pub unsafe fn flags_clobber() {
asm!("", options(nostack, nomem));
}

// CHECK-LABEL: @no_clobber
// CHECK: call void asm sideeffect "", ""()
#[no_mangle]
pub unsafe fn no_clobber() {
asm!("", options(nostack, nomem, preserves_flags));
}
Loading