Skip to content

Commit

Permalink
CHECK only for opaque ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Jul 27, 2023
1 parent 190ded8 commit da47736
Show file tree
Hide file tree
Showing 52 changed files with 251 additions and 251 deletions.
2 changes: 1 addition & 1 deletion tests/codegen/abi-main-signature-32bit-c-int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
fn main() {
}

// CHECK: define{{( hidden)?}} i32 @main(i32{{( %0)?}}, {{i8\*\*|ptr}}{{( %1)?}})
// CHECK: define{{( hidden)?}} i32 @main(i32{{( %0)?}}, ptr{{( %1)?}})
6 changes: 3 additions & 3 deletions tests/codegen/adjustments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub fn helper(_: usize) {
pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
// We used to generate an extra alloca and memcpy for the block's trailing expression value, so
// check that we copy directly to the return value slot
// CHECK: %0 = insertvalue { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } poison, {{\[0 x i8\]\*|ptr}} %x.0, 0
// CHECK: %1 = insertvalue { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } %0, [[USIZE]] %x.1, 1
// CHECK: ret { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } %1
// CHECK: %0 = insertvalue { ptr, [[USIZE]] } poison, ptr %x.0, 0
// CHECK: %1 = insertvalue { ptr, [[USIZE]] } %0, [[USIZE]] %x.1, 1
// CHECK: ret { ptr, [[USIZE]] } %1
{ x }
}

Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/align-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Nested64 {
#[no_mangle]
pub fn align64(a: u32) -> Align64 {
// CHECK: %a64 = alloca %Align64, align 64
// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 64 %{{.*}}, {{i8\*|ptr}} align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
let a64 = Align64::A(a);
a64
}
Expand Down
4 changes: 2 additions & 2 deletions tests/codegen/align-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum Enum64 {
#[no_mangle]
pub fn align64(i : i32) -> Align64 {
// CHECK: %a64 = alloca %Align64, align 64
// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 64 %{{.*}}, {{i8\*|ptr}} align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
let a64 = Align64(i);
a64
}
Expand All @@ -42,7 +42,7 @@ pub fn align64(i : i32) -> Align64 {
// CHECK-LABEL: @align64_load
#[no_mangle]
pub fn align64_load(a: Align64) -> i32 {
// CHECK: {{%.*}} = load i32, {{i32\*|ptr}} {{%.*}}, align 64
// CHECK: {{%.*}} = load i32, ptr {{%.*}}, align 64
a.0
}

Expand Down
8 changes: 4 additions & 4 deletions tests/codegen/array-equality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub fn array_eq_value(a: [u16; 3], b: [u16; 3]) -> bool {
#[no_mangle]
pub fn array_eq_ref(a: &[u16; 3], b: &[u16; 3]) -> bool {
// CHECK: start:
// CHECK: load i48, {{i48\*|ptr}} %{{.+}}, align 2
// CHECK: load i48, {{i48\*|ptr}} %{{.+}}, align 2
// CHECK: load i48, ptr %{{.+}}, align 2
// CHECK: load i48, ptr %{{.+}}, align 2
// CHECK: icmp eq i48
// CHECK-NEXT: ret
a == b
Expand All @@ -27,7 +27,7 @@ pub fn array_eq_ref(a: &[u16; 3], b: &[u16; 3]) -> bool {
#[no_mangle]
pub fn array_eq_value_still_passed_by_pointer(a: [u16; 9], b: [u16; 9]) -> bool {
// CHECK-NEXT: start:
// CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{i8\*|ptr}} {{.*}} dereferenceable(18) %{{.+}}, {{i8\*|ptr}} {{.*}} dereferenceable(18) %{{.+}}, i64 18)
// CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}(ptr {{.*}} dereferenceable(18) %{{.+}}, ptr {{.*}} dereferenceable(18) %{{.+}}, i64 18)
// CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[CMP]], 0
// CHECK-NEXT: ret i1 %[[EQ]]
a == b
Expand All @@ -37,7 +37,7 @@ pub fn array_eq_value_still_passed_by_pointer(a: [u16; 9], b: [u16; 9]) -> bool
#[no_mangle]
pub fn array_eq_long(a: &[u16; 1234], b: &[u16; 1234]) -> bool {
// CHECK-NEXT: start:
// CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{i8\*|ptr}} {{.*}} dereferenceable(2468) %{{.+}}, {{i8\*|ptr}} {{.*}} dereferenceable(2468) %{{.+}}, i64 2468)
// CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}(ptr {{.*}} dereferenceable(2468) %{{.+}}, ptr {{.*}} dereferenceable(2468) %{{.+}}, i64 2468)
// CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[CMP]], 0
// CHECK-NEXT: ret i1 %[[EQ]]
a == b
Expand Down
60 changes: 30 additions & 30 deletions tests/codegen/atomic-operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ use std::sync::atomic::{AtomicI32, Ordering::*};
// CHECK-LABEL: @compare_exchange
#[no_mangle]
pub fn compare_exchange(a: &AtomicI32) {
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 10 monotonic monotonic
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 11 monotonic acquire
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 12 monotonic seq_cst
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 10 monotonic monotonic
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 11 monotonic acquire
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 12 monotonic seq_cst
let _ = a.compare_exchange(0, 10, Relaxed, Relaxed);
let _ = a.compare_exchange(0, 11, Relaxed, Acquire);
let _ = a.compare_exchange(0, 12, Relaxed, SeqCst);

// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 20 release monotonic
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 21 release acquire
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 22 release seq_cst
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 20 release monotonic
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 21 release acquire
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 22 release seq_cst
let _ = a.compare_exchange(0, 20, Release, Relaxed);
let _ = a.compare_exchange(0, 21, Release, Acquire);
let _ = a.compare_exchange(0, 22, Release, SeqCst);

// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 30 acquire monotonic
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 31 acquire acquire
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 32 acquire seq_cst
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 30 acquire monotonic
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 31 acquire acquire
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 32 acquire seq_cst
let _ = a.compare_exchange(0, 30, Acquire, Relaxed);
let _ = a.compare_exchange(0, 31, Acquire, Acquire);
let _ = a.compare_exchange(0, 32, Acquire, SeqCst);

// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 40 acq_rel monotonic
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 41 acq_rel acquire
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 42 acq_rel seq_cst
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 40 acq_rel monotonic
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 41 acq_rel acquire
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 42 acq_rel seq_cst
let _ = a.compare_exchange(0, 40, AcqRel, Relaxed);
let _ = a.compare_exchange(0, 41, AcqRel, Acquire);
let _ = a.compare_exchange(0, 42, AcqRel, SeqCst);

// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 50 seq_cst monotonic
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 51 seq_cst acquire
// CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 52 seq_cst seq_cst
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 50 seq_cst monotonic
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 51 seq_cst acquire
// CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 52 seq_cst seq_cst
let _ = a.compare_exchange(0, 50, SeqCst, Relaxed);
let _ = a.compare_exchange(0, 51, SeqCst, Acquire);
let _ = a.compare_exchange(0, 52, SeqCst, SeqCst);
Expand All @@ -46,37 +46,37 @@ pub fn compare_exchange(a: &AtomicI32) {
// CHECK-LABEL: @compare_exchange_weak
#[no_mangle]
pub fn compare_exchange_weak(w: &AtomicI32) {
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 10 monotonic monotonic
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 11 monotonic acquire
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 12 monotonic seq_cst
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 10 monotonic monotonic
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 11 monotonic acquire
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 12 monotonic seq_cst
let _ = w.compare_exchange_weak(1, 10, Relaxed, Relaxed);
let _ = w.compare_exchange_weak(1, 11, Relaxed, Acquire);
let _ = w.compare_exchange_weak(1, 12, Relaxed, SeqCst);

// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 20 release monotonic
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 21 release acquire
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 22 release seq_cst
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 20 release monotonic
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 21 release acquire
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 22 release seq_cst
let _ = w.compare_exchange_weak(1, 20, Release, Relaxed);
let _ = w.compare_exchange_weak(1, 21, Release, Acquire);
let _ = w.compare_exchange_weak(1, 22, Release, SeqCst);

// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 30 acquire monotonic
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 31 acquire acquire
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 32 acquire seq_cst
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 30 acquire monotonic
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 31 acquire acquire
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 32 acquire seq_cst
let _ = w.compare_exchange_weak(1, 30, Acquire, Relaxed);
let _ = w.compare_exchange_weak(1, 31, Acquire, Acquire);
let _ = w.compare_exchange_weak(1, 32, Acquire, SeqCst);

// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 40 acq_rel monotonic
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 41 acq_rel acquire
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 42 acq_rel seq_cst
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 40 acq_rel monotonic
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 41 acq_rel acquire
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 42 acq_rel seq_cst
let _ = w.compare_exchange_weak(1, 40, AcqRel, Relaxed);
let _ = w.compare_exchange_weak(1, 41, AcqRel, Acquire);
let _ = w.compare_exchange_weak(1, 42, AcqRel, SeqCst);

// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 50 seq_cst monotonic
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 51 seq_cst acquire
// CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 52 seq_cst seq_cst
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 50 seq_cst monotonic
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 51 seq_cst acquire
// CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 52 seq_cst seq_cst
let _ = w.compare_exchange_weak(1, 50, SeqCst, Relaxed);
let _ = w.compare_exchange_weak(1, 51, SeqCst, Acquire);
let _ = w.compare_exchange_weak(1, 52, SeqCst, SeqCst);
Expand Down
6 changes: 3 additions & 3 deletions tests/codegen/avr/avr-func-addrspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ pub extern "C" fn test() {

// Validate that we can codegen transmutes between data ptrs and fn ptrs.

// CHECK: define{{.+}}{{void \(\) addrspace\(1\)\*|ptr addrspace\(1\)}} @transmute_data_ptr_to_fn({{\{\}\*|ptr}}{{.*}} %x)
// CHECK: define{{.+}}ptr addrspace(1) @transmute_data_ptr_to_fn(ptr{{.*}} %x)
#[no_mangle]
pub unsafe fn transmute_data_ptr_to_fn(x: *const ()) -> fn() {
// It doesn't matter precisely how this is codegenned (through memory or an addrspacecast),
// as long as it doesn't cause a verifier error by using `bitcast`.
transmute(x)
}

// CHECK: define{{.+}}{{\{\}\*|ptr}} @transmute_fn_ptr_to_data({{void \(\) addrspace\(1\)\*|ptr addrspace\(1\)}}{{.*}} %x)
// CHECK: define{{.+}}ptr @transmute_fn_ptr_to_data(ptr addrspace(1){{.*}} %x)
#[no_mangle]
pub unsafe fn transmute_fn_ptr_to_data(x: fn()) -> *const () {
// It doesn't matter precisely how this is codegenned (through memory or an addrspacecast),
Expand All @@ -116,7 +116,7 @@ pub enum Either<T, U> { A(T), B(U) }
// with the `ptr` field representing both `&i32` and `fn()` depending on the variant.
// This is incorrect, because `fn()` should be `ptr addrspace(1)`, not `ptr`.

// CHECK: define{{.+}}void @should_not_combine_addrspace({{.+\*|ptr}}{{.+}}sret{{.+}}%_0, {{.+\*|ptr}}{{.+}}%x)
// CHECK: define{{.+}}void @should_not_combine_addrspace(ptr{{.+}}sret{{.+}}%_0, ptr{{.+}}%x)
#[no_mangle]
#[inline(never)]
pub fn should_not_combine_addrspace(x: Either<&i32, fn()>) -> Either<&i32, fn()> {
Expand Down
4 changes: 2 additions & 2 deletions tests/codegen/drop-in-place-noalias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

use std::marker::PhantomPinned;

// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}({{.*\*|ptr}} noalias noundef align 4 dereferenceable(12) %{{.+}})
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}(ptr noalias noundef align 4 dereferenceable(12) %{{.+}})

// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}({{.*\*|ptr}} noundef nonnull align 4 %{{.+}})
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}(ptr noundef nonnull align 4 %{{.+}})

pub struct StructUnpin {
a: i32,
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/fastcall-inreg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod tests {
#[no_mangle]
pub extern "fastcall" fn f1(_: i32, _: i32, _: i32) {}

// CHECK: @f2({{i32\*|ptr}} inreg noundef %_1, {{i32\*|ptr}} inreg noundef %_2, {{i32\*|ptr}} noundef %_3)
// CHECK: @f2(ptr inreg noundef %_1, ptr inreg noundef %_2, ptr noundef %_3)
#[no_mangle]
pub extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {}

Expand Down
10 changes: 5 additions & 5 deletions tests/codegen/function-arguments-noopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ pub fn boolean_call(x: bool, f: fn(bool) -> bool) -> bool {
f(x)
}

// CHECK: align 4 {{i32\*|ptr}} @borrow({{i32\*|ptr}} align 4 %x)
// CHECK: align 4 ptr @borrow(ptr align 4 %x)
#[no_mangle]
pub fn borrow(x: &i32) -> &i32 {
x
}

// CHECK: align 4 {{i32\*|ptr}} @borrow_mut({{i32\*|ptr}} align 4 %x)
// CHECK: align 4 ptr @borrow_mut(ptr align 4 %x)
#[no_mangle]
pub fn borrow_mut(x: &mut i32) -> &mut i32 {
x
Expand All @@ -38,11 +38,11 @@ pub fn borrow_mut(x: &mut i32) -> &mut i32 {
// CHECK-LABEL: @borrow_call
#[no_mangle]
pub fn borrow_call(x: &i32, f: fn(&i32) -> &i32) -> &i32 {
// CHECK: call align 4 {{i32\*|ptr}} %f({{i32\*|ptr}} align 4 %x)
// CHECK: call align 4 ptr %f(ptr align 4 %x)
f(x)
}

// CHECK: void @struct_({{%S\*|ptr}} sret(%S) align 4{{( %_0)?}}, {{%S\*|ptr}} align 4 %x)
// CHECK: void @struct_(ptr sret(%S) align 4{{( %_0)?}}, ptr align 4 %x)
#[no_mangle]
pub fn struct_(x: S) -> S {
x
Expand All @@ -51,7 +51,7 @@ pub fn struct_(x: S) -> S {
// CHECK-LABEL: @struct_call
#[no_mangle]
pub fn struct_call(x: S, f: fn(S) -> S) -> S {
// CHECK: call void %f({{%S\*|ptr}} sret(%S) align 4{{( %_0)?}}, {{%S\*|ptr}} align 4 %{{.+}})
// CHECK: call void %f(ptr sret(%S) align 4{{( %_0)?}}, ptr align 4 %{{.+}})
f(x)
}

Expand Down
Loading

0 comments on commit da47736

Please sign in to comment.