Skip to content

Commit b1eca7b

Browse files
committed
make the codegen test also cover an ill-behaved arch, and add links
1 parent 697787a commit b1eca7b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+2
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
737737
// a hint, and use regular stores everywhere else.
738738
// (In the future, we could alternatively ensure that an sfence gets emitted after a sequence of movnt
739739
// before any kind of synchronizing operation. But it's not clear how to do that with LLVM.)
740+
// For more context, see <https://github.com/rust-lang/rust/issues/114582> and
741+
// <https://github.com/llvm/llvm-project/issues/64521>.
740742
const WELL_BEHAVED_NONTEMPORAL_ARCHS: &[&str] =
741743
&["aarch64", "arm", "riscv32", "riscv64"];
742744

tests/codegen/intrinsics/nontemporal.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
//@ compile-flags: -O
2-
//@ compile-flags: --target aarch64-unknown-linux-gnu
3-
//@ needs-llvm-components: aarch64
2+
//@revisions: with_nontemporal without_nontemporal
3+
//@[with_nontemporal] compile-flags: --target aarch64-unknown-linux-gnu
4+
//@[with_nontemporal] needs-llvm-components: aarch64
5+
//@[without_nontemporal] compile-flags: --target x86_64-unknown-linux-gnu
6+
//@[without_nontemporal] needs-llvm-components: x86
7+
8+
// Ensure that we *do* eomit the `!nonteporal` flag on architectures where it
9+
// is well-behaved, but do *not* emit it on architectures where it is ill-behaved.
10+
// For more context, see <https://github.com/rust-lang/rust/issues/114582> and
11+
// <https://github.com/llvm/llvm-project/issues/64521>.
412

513
#![feature(no_core, lang_items, intrinsics)]
614
#![no_core]
@@ -21,7 +29,8 @@ extern "rust-intrinsic" {
2129
#[no_mangle]
2230
pub fn a(a: &mut u32, b: u32) {
2331
// CHECK-LABEL: define{{.*}}void @a
24-
// CHECK: store i32 %b, ptr %a, align 4, !nontemporal
32+
// with_nontemporal: store i32 %b, ptr %a, align 4, !nontemporal
33+
// without_nontemporal-NOT: nontemporal
2534
unsafe {
2635
nontemporal_store(a, b);
2736
}

0 commit comments

Comments
 (0)