make the codegen test also cover an ill-behaved arch, and add links

This commit is contained in:
Ralf Jung 2024-08-12 11:10:26 +02:00
parent 697787a92d
commit 75743dc5a0
2 changed files with 14 additions and 3 deletions

View File

@ -737,6 +737,8 @@ fn store_with_flags(
// a hint, and use regular stores everywhere else.
// (In the future, we could alternatively ensure that an sfence gets emitted after a sequence of movnt
// before any kind of synchronizing operation. But it's not clear how to do that with LLVM.)
// For more context, see <https://github.com/rust-lang/rust/issues/114582> and
// <https://github.com/llvm/llvm-project/issues/64521>.
const WELL_BEHAVED_NONTEMPORAL_ARCHS: &[&str] =
&["aarch64", "arm", "riscv32", "riscv64"];

View File

@ -1,6 +1,14 @@
//@ compile-flags: -O
//@ compile-flags: --target aarch64-unknown-linux-gnu
//@ needs-llvm-components: aarch64
//@revisions: with_nontemporal without_nontemporal
//@[with_nontemporal] compile-flags: --target aarch64-unknown-linux-gnu
//@[with_nontemporal] needs-llvm-components: aarch64
//@[without_nontemporal] compile-flags: --target x86_64-unknown-linux-gnu
//@[without_nontemporal] needs-llvm-components: x86
// Ensure that we *do* emit the `!nontemporal` flag on architectures where it
// is well-behaved, but do *not* emit it on architectures where it is ill-behaved.
// For more context, see <https://github.com/rust-lang/rust/issues/114582> and
// <https://github.com/llvm/llvm-project/issues/64521>.
#![feature(no_core, lang_items, intrinsics)]
#![no_core]
@ -21,7 +29,8 @@ impl<T> Copy for *mut T {}
#[no_mangle]
pub fn a(a: &mut u32, b: u32) {
// CHECK-LABEL: define{{.*}}void @a
// CHECK: store i32 %b, ptr %a, align 4, !nontemporal
// with_nontemporal: store i32 %b, ptr %a, align 4, !nontemporal
// without_nontemporal-NOT: nontemporal
unsafe {
nontemporal_store(a, b);
}