Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f125538

Browse files
committed
Add more codegen tests
1 parent af23ad9 commit f125538

26 files changed

+166
-139
lines changed

tests/codegen/abi-sysv64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// of the sysv64 abi.
44
//
55
// needs-llvm-components: x86
6-
// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu
6+
// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu -Copt-level=0
77

88
#![crate_type = "lib"]
99
#![no_core]
@@ -15,7 +15,7 @@ trait Sized {}
1515
trait Copy {}
1616
impl Copy for i64 {}
1717

18-
// CHECK: define x86_64_sysvcc noundef i64 @has_sysv64_abi
18+
// CHECK: define x86_64_sysvcc i64 @has_sysv64_abi
1919
#[no_mangle]
2020
pub extern "sysv64" fn has_sysv64_abi(a: i64) -> i64 {
2121
a

tests/codegen/abi-x86-interrupt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// of the x86-interrupt abi.
44

55
// needs-llvm-components: x86
6-
// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu
6+
// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu -Copt-level=0
77

88
#![crate_type = "lib"]
99
#![no_core]
@@ -15,7 +15,7 @@ trait Sized {}
1515
trait Copy {}
1616
impl Copy for i64 {}
1717

18-
// CHECK: define x86_intrcc noundef i64 @has_x86_interrupt_abi
18+
// CHECK: define x86_intrcc i64 @has_x86_interrupt_abi
1919
#[no_mangle]
2020
pub extern "x86-interrupt" fn has_x86_interrupt_abi(a: i64) -> i64 {
2121
a

tests/codegen/adjustments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// compile-flags: -C no-prepopulate-passes
1+
// compile-flags: -C no-prepopulate-passes -Copt-level=0
22

33
#![crate_type = "lib"]
44

55
// Hack to get the correct size for the length part in slices
6-
// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1)
6+
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
77
#[no_mangle]
88
pub fn helper(_: usize) {
99
}

tests/codegen/c-variadic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ignore-wasm32-bare compiled with panic=abort by default
2-
// compile-flags: -C no-prepopulate-passes
2+
// compile-flags: -C no-prepopulate-passes -Copt-level=0
33
//
44

55
#![crate_type = "lib"]
@@ -15,7 +15,7 @@ extern "C" {
1515

1616
pub unsafe extern "C" fn use_foreign_c_variadic_0() {
1717
// Ensure that we correctly call foreign C-variadic functions.
18-
// CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32 noundef( signext)?]] 0)
18+
// CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32( signext)?]] 0)
1919
foreign_c_variadic_0(0);
2020
// CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42)
2121
foreign_c_variadic_0(0, 42i32);
@@ -61,7 +61,7 @@ pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 {
6161
// Ensure that we generate the correct `call` signature when calling a Rust
6262
// defined C-variadic.
6363
pub unsafe fn test_c_variadic_call() {
64-
// CHECK: call [[RET:noundef( signext)? i32]] (i32, ...) @c_variadic([[PARAM]] 0)
64+
// CHECK: call [[RET:(signext )?i32]] (i32, ...) @c_variadic([[PARAM]] 0)
6565
c_variadic(0);
6666
// CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42)
6767
c_variadic(0, 42i32);

tests/codegen/call-llvm-intrinsics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -C no-prepopulate-passes
1+
// compile-flags: -C no-prepopulate-passes -Copt-level=0
22

33
// ignore-riscv64
44

@@ -23,7 +23,7 @@ pub fn do_call() {
2323

2424
unsafe {
2525
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
26-
// CHECK: call noundef float @llvm.sqrt.f32(float noundef 4.000000e+00
26+
// CHECK: call float @llvm.sqrt.f32(float 4.000000e+00
2727
sqrt(4.0);
2828
}
2929
}

tests/codegen/dllimports/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This test is for *-windows-msvc only.
1+
// This test is for *-windows-msvc only.
22
// only-windows
33
// ignore-gnu
44

@@ -15,10 +15,10 @@ extern crate wrapper;
1515
// CHECK: @static_global1 = external local_unnamed_addr global i32
1616
// CHECK: @static_global2 = external local_unnamed_addr global i32
1717

18-
// CHECK: declare dllimport i32 @dylib_func1(i32)
19-
// CHECK: declare dllimport i32 @dylib_func2(i32)
20-
// CHECK: declare i32 @static_func1(i32)
21-
// CHECK: declare i32 @static_func2(i32)
18+
// CHECK: declare dllimport noundef i32 @dylib_func1(i32 noundef)
19+
// CHECK: declare dllimport noundef i32 @dylib_func2(i32 noundef)
20+
// CHECK: declare noundef i32 @static_func1(i32 noundef)
21+
// CHECK: declare noundef i32 @static_func2(i32 noundef)
2222

2323
#[link(name = "dummy", kind="dylib")]
2424
extern "C" {

tests/codegen/frame-pointer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: --crate-type=rlib
1+
// compile-flags: --crate-type=rlib -Copt-level=0
22
// revisions: aarch64-apple aarch64-linux force x64-apple x64-linux
33
// [aarch64-apple] needs-llvm-components: aarch64
44
// [aarch64-apple] compile-flags: --target=aarch64-apple-darwin
@@ -20,7 +20,7 @@ trait Copy { }
2020
impl Copy for u32 {}
2121

2222

23-
// CHECK: define noundef i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {
23+
// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {
2424
#[no_mangle]
2525
pub fn peach(x: u32) -> u32 {
2626
x

tests/codegen/function-arguments.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// compile-flags: -O -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
#![feature(rustc_attrs)]
54

65
use std::mem::MaybeUninit;
76
use std::num::NonZeroU64;
87
use std::marker::PhantomPinned;
8+
use std::ptr::NonNull;
99

1010
pub struct S {
1111
_field: [i32; 8],
@@ -138,11 +138,27 @@ pub fn indirect_struct(_: S) {
138138
pub fn borrowed_struct(_: &S) {
139139
}
140140

141+
// CHECK: @option_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable_or_null(4) %x)
142+
#[no_mangle]
143+
pub fn option_borrow(x: Option<&i32>) {
144+
}
145+
146+
// CHECK: @option_borrow_mut({{i32\*|ptr}} noalias noundef align 4 dereferenceable_or_null(4) %x)
147+
#[no_mangle]
148+
pub fn option_borrow_mut(x: Option<&mut i32>) {
149+
}
150+
141151
// CHECK: @raw_struct({{%S\*|ptr}} noundef %_1)
142152
#[no_mangle]
143153
pub fn raw_struct(_: *const S) {
144154
}
145155

156+
// CHECK: @raw_option_nonnull_struct({{i32\*|ptr}} noundef %_1)
157+
#[no_mangle]
158+
pub fn raw_option_nonnull_struct(_: Option<NonNull<S>>) {
159+
}
160+
161+
146162
// `Box` can get deallocated during execution of the function, so it should
147163
// not get `dereferenceable`.
148164
// CHECK: noundef nonnull align 4 {{i32\*|ptr}} @_box({{i32\*|ptr}} noalias noundef nonnull align 4 %x)
@@ -200,6 +216,16 @@ pub fn str(_: &[u8]) {
200216
pub fn trait_borrow(_: &dyn Drop) {
201217
}
202218

219+
// CHECK: @option_trait_borrow({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1)
220+
#[no_mangle]
221+
pub fn option_trait_borrow(x: Option<&dyn Drop>) {
222+
}
223+
224+
// CHECK: @option_trait_borrow_mut({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1)
225+
#[no_mangle]
226+
pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) {
227+
}
228+
203229
// CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
204230
#[no_mangle]
205231
pub fn trait_raw(_: *const dyn Drop) {

tests/codegen/intrinsics/const_eval_select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -C no-prepopulate-passes
1+
// compile-flags: -C no-prepopulate-passes -Copt-level=0
22

33
#![crate_type = "lib"]
44
#![feature(const_eval_select)]
@@ -13,6 +13,6 @@ pub fn hi(n: i32) -> i32 { n }
1313

1414
#[no_mangle]
1515
pub unsafe fn hey() {
16-
// CHECK: call noundef i32 @hi(i32
16+
// CHECK: call i32 @hi(i32
1717
const_eval_select((42,), foo, hi);
1818
}

tests/codegen/intrinsics/mask.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
// compile-flags: -Copt-level=0
12
#![crate_type = "lib"]
23
#![feature(core_intrinsics)]
34

45
// CHECK-LABEL: @mask_ptr
5-
// CHECK-SAME: [[WORD:i[0-9]+]] noundef %mask
6+
// CHECK-SAME: [[WORD:i[0-9]+]] %mask
67
#[no_mangle]
78
pub fn mask_ptr(ptr: *const u16, mask: usize) -> *const u16 {
89
// CHECK: call
9-
// CHECK-SAME: @llvm.ptrmask.{{p0|p0i8}}.[[WORD]]({{ptr|i8\*}} {{%ptr|%0}}, [[WORD]] %mask)
10+
// CHECK-SAME: @llvm.ptrmask.{{p0|p0i8}}.[[WORD]]({{ptr|i8\*}} {{%ptr|%1}}, [[WORD]] %mask)
1011
core::intrinsics::ptr_mask(ptr, mask)
1112
}

0 commit comments

Comments
 (0)