Skip to content

Commit 3a03bb9

Browse files
authored
Rollup merge of #144567 - CaiWeiran:transmute-scalar_test, r=nikic
Fix RISC-V Test Failures in ./x test for Multiple Codegen Cases This PR resolves several test failures encountered when running `./x test` on the RISC-V architecture. These failures were caused by platform-specific behavior, ABI differences, or codegen inconsistencies unique to RISC-V. The following test cases have been fixed to ensure compatibility with RISC-V: * `codegen-llvm/enum/enum-match.rs` * `codegen-llvm/enum/enum-transparent-extract.rs` * `codegen-llvm/repeat-operand-zero-len.rs` * `codegen-llvm/enum/enum-aggregate.rs` * `codegen-llvm/uninhabited-transparent-return-abi.rs` In addition, this PR adjusts `tests/codegen-llvm/transmute-scalar.rs` to explicitly specify the target architecture: ```rust //@ compile-flags: --target=x86_64-unknown-linux-gnu //@ needs-llvm-components: x86 ``` As suggested by ```@nikic,``` this test is not target-specific and already uses `minicore`, implying it is meant to run against a stable triple regardless of the host architecture. Explicitly setting the target ensures consistent codegen behavior, particularly when testing on non-x86 platforms such as riscv64. All changes have been tested locally on a RISC-V target and now pass as expected. ### Notes: * These fixes are scoped specifically to enable full test suite compliance for RISC-V. * No changes impact other architectures. * The change to `transmute-scalar.rs` aligns with the intent of [[#143915](https://github.com/rust-lang/rust/pull/143915)](https://github.com/rust-lang/rust/pull/143915) and prevents architecture-dependent discrepancies during CI or local testing.
2 parents d6645f7 + 9d08596 commit 3a03bb9

File tree

6 files changed

+12
-19
lines changed

6 files changed

+12
-19
lines changed

tests/codegen-llvm/enum/enum-aggregate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ fn make_none_bool() -> Option<bool> {
2727

2828
#[no_mangle]
2929
fn make_some_ordering(x: Ordering) -> Option<Ordering> {
30-
// CHECK-LABEL: i8 @make_some_ordering(i8 %x)
30+
// CHECK-LABEL: i8 @make_some_ordering(i8{{( signext)?}} %x)
3131
// CHECK-NEXT: start:
3232
// CHECK-NEXT: ret i8 %x
3333
Some(x)
3434
}
3535

3636
#[no_mangle]
3737
fn make_some_u16(x: u16) -> Option<u16> {
38-
// CHECK-LABEL: { i16, i16 } @make_some_u16(i16 %x)
38+
// CHECK-LABEL: { i16, i16 } @make_some_u16(i16{{( zeroext)?}} %x)
3939
// CHECK-NEXT: start:
4040
// CHECK-NEXT: %0 = insertvalue { i16, i16 } { i16 1, i16 poison }, i16 %x, 1
4141
// CHECK-NEXT: ret { i16, i16 } %0
@@ -52,7 +52,7 @@ fn make_none_u16() -> Option<u16> {
5252

5353
#[no_mangle]
5454
fn make_some_nzu32(x: NonZero<u32>) -> Option<NonZero<u32>> {
55-
// CHECK-LABEL: i32 @make_some_nzu32(i32 %x)
55+
// CHECK-LABEL: i32 @make_some_nzu32(i32{{( signext)?}} %x)
5656
// CHECK-NEXT: start:
5757
// CHECK-NEXT: ret i32 %x
5858
Some(x)
@@ -114,7 +114,7 @@ fn make_uninhabited_err_indirectly(n: Never) -> Result<u32, Never> {
114114
fn make_fully_uninhabited_result(v: u32, n: Never) -> Result<(u32, Never), (Never, u32)> {
115115
// Actually reaching this would be UB, so we don't actually build a result.
116116

117-
// CHECK-LABEL: { i32, i32 } @make_fully_uninhabited_result(i32 %v)
117+
// CHECK-LABEL: { i32, i32 } @make_fully_uninhabited_result(i32{{( signext)?}} %v)
118118
// CHECK-NEXT: start:
119119
// CHECK-NEXT: call void @llvm.trap()
120120
// CHECK-NEXT: call void @llvm.trap()

tests/codegen-llvm/enum/enum-match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ pub enum Tricky {
739739

740740
const _: () = assert!(std::intrinsics::discriminant_value(&Tricky::V100) == 100);
741741

742-
// CHECK-LABEL: define noundef{{( range\(i8 [0-9]+, [0-9]+\))?}} i8 @discriminant6(i8 noundef %e)
742+
// CHECK-LABEL: define noundef{{( range\(i8 [0-9]+, [0-9]+\))?}} i8 @discriminant6(i8 noundef{{( zeroext)?}} %e)
743743
// CHECK-NEXT: start:
744744
// CHECK-NEXT: %[[REL_VAR:.+]] = add i8 %e, -66
745745
// CHECK-NEXT: %[[IS_NICHE:.+]] = icmp ult i8 %[[REL_VAR]], -56

tests/codegen-llvm/enum/enum-transparent-extract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub enum Never {}
99

1010
#[no_mangle]
1111
pub fn make_unmake_result_never(x: i32) -> i32 {
12-
// CHECK-LABEL: define i32 @make_unmake_result_never(i32 %x)
12+
// CHECK-LABEL: define i32 @make_unmake_result_never(i32{{( signext)?}} %x)
1313
// CHECK: start:
1414
// CHECK-NEXT: ret i32 %x
1515

tests/codegen-llvm/repeat-operand-zero-len.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#[repr(transparent)]
1212
pub struct Wrapper<T, const N: usize>([T; N]);
1313

14-
// CHECK-LABEL: define {{.+}}do_repeat{{.+}}(i32 noundef %x)
14+
// CHECK-LABEL: define {{.+}}do_repeat{{.+}}(i32 noundef{{( signext)?}} %x)
1515
// CHECK-NEXT: start:
1616
// CHECK-NOT: alloca
1717
// CHECK-NEXT: ret void
@@ -23,6 +23,6 @@ pub fn do_repeat<T: Copy, const N: usize>(x: T) -> Wrapper<T, N> {
2323
// CHECK-LABEL: @trigger_repeat_zero_len
2424
#[no_mangle]
2525
pub fn trigger_repeat_zero_len() -> Wrapper<u32, 0> {
26-
// CHECK: call void {{.+}}do_repeat{{.+}}(i32 noundef 4)
26+
// CHECK: call void {{.+}}do_repeat{{.+}}(i32 noundef{{( signext)?}} 4)
2727
do_repeat(4)
2828
}

tests/codegen-llvm/transmute-scalar.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//@ add-core-stubs
2-
//@ compile-flags: -C opt-level=0 -C no-prepopulate-passes
2+
//@ compile-flags: -C opt-level=0 -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu
3+
//@ needs-llvm-components: x86
34

45
#![crate_type = "lib"]
5-
#![feature(no_core, repr_simd, arm_target_feature, mips_target_feature, s390x_target_feature)]
6+
#![feature(no_core, repr_simd)]
67
#![no_core]
78
extern crate minicore;
89

@@ -117,11 +118,7 @@ struct S([i64; 1]);
117118
// CHECK-NEXT: %[[TEMP:.+]] = load i64, ptr %[[RET]]
118119
// CHECK-NEXT: ret i64 %[[TEMP]]
119120
#[no_mangle]
120-
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
121-
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
122121
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
123-
#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))]
124-
#[cfg_attr(target_arch = "s390x", target_feature(enable = "vector"))]
125122
pub extern "C" fn single_element_simd_to_scalar(b: S) -> i64 {
126123
unsafe { mem::transmute(b) }
127124
}
@@ -133,11 +130,7 @@ pub extern "C" fn single_element_simd_to_scalar(b: S) -> i64 {
133130
// CHECK-NEXT: %[[TEMP:.+]] = load <1 x i64>, ptr %[[RET]]
134131
// CHECK-NEXT: ret <1 x i64> %[[TEMP]]
135132
#[no_mangle]
136-
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
137-
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
138133
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
139-
#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))]
140-
#[cfg_attr(target_arch = "s390x", target_feature(enable = "vector"))]
141134
pub extern "C" fn scalar_to_single_element_simd(b: i64) -> S {
142135
unsafe { mem::transmute(b) }
143136
}

tests/codegen-llvm/uninhabited-transparent-return-abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn test_uninhabited_ret_by_ref() {
3636
pub fn test_uninhabited_ret_by_ref_with_arg(rsi: u32) {
3737
// CHECK: %_2 = alloca [24 x i8], align {{8|4}}
3838
// CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 24, )?}}ptr nonnull %_2)
39-
// CHECK-NEXT: call void @opaque_with_arg({{.*}} sret([24 x i8]) {{.*}} %_2, i32 noundef %rsi) #2
39+
// CHECK-NEXT: call void @opaque_with_arg({{.*}} sret([24 x i8]) {{.*}} %_2, i32 noundef{{( signext)?}} %rsi) #2
4040
// CHECK-NEXT: unreachable
4141
unsafe {
4242
opaque_with_arg(rsi);

0 commit comments

Comments
 (0)