mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
tests: accept new GEP source element type
This commit is contained in:
@@ -11,27 +11,27 @@
|
||||
// CHECK-LABEL: @index_on_struct(
|
||||
#[no_mangle]
|
||||
fn index_on_struct(a: &[Foo], index: usize) -> &Foo {
|
||||
// CHECK: getelementptr inbounds{{( nuw)?}} %Foo, ptr %a.0, {{i64|i32}} %index
|
||||
// CHECK: getelementptr inbounds{{( nuw)?}} {{%Foo|\[8 x i8\]}}, ptr %a.0, {{i64|i32}} %index
|
||||
&a[index]
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @offset_on_struct(
|
||||
#[no_mangle]
|
||||
fn offset_on_struct(a: *const Foo, index: usize) -> *const Foo {
|
||||
// CHECK: getelementptr inbounds{{( nuw)?}} %Foo, ptr %a, {{i64|i32}} %index
|
||||
// CHECK: getelementptr inbounds{{( nuw)?}} {{%Foo|\[8 x i8\]}}, ptr %a, {{i64|i32}} %index
|
||||
unsafe { a.add(index) }
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @index_on_i32(
|
||||
#[no_mangle]
|
||||
fn index_on_i32(a: &[i32], index: usize) -> &i32 {
|
||||
// CHECK: getelementptr inbounds{{( nuw)?}} i32, ptr %a.0, {{i64|i32}} %index
|
||||
// CHECK: getelementptr inbounds{{( nuw)?}} {{i32|\[4 x i8\]}}, ptr %a.0, {{i64|i32}} %index
|
||||
&a[index]
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @offset_on_i32(
|
||||
#[no_mangle]
|
||||
fn offset_on_i32(a: *const i32, index: usize) -> *const i32 {
|
||||
// CHECK: getelementptr inbounds{{( nuw)?}} i32, ptr %a, {{i64|i32}} %index
|
||||
// CHECK: getelementptr inbounds{{( nuw)?}} {{i32|\[4 x i8\]}}, ptr %a, {{i64|i32}} %index
|
||||
unsafe { a.add(index) }
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ pub fn branchy(input: u64) -> u64 {
|
||||
// CHECK-LABEL: @branchy(
|
||||
// CHECK-NEXT: start:
|
||||
// CHECK-NEXT: [[_2:%.*]] = and i64 [[INPUT:%.*]], 3
|
||||
// CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds{{( nuw)?}} {{\[4 x i64\]|i64}}, ptr @switch.table.branchy{{(, i64 0)?}}, i64 [[_2]]
|
||||
// CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds{{( nuw)?}} {{\[4 x i64\]|i64|\[8 x i8\]}}, ptr @switch.table.branchy{{(, i64 0)?}}, i64 [[_2]]
|
||||
// CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]]
|
||||
// CHECK-NEXT: ret i64 [[SWITCH_LOAD]]
|
||||
match input % 4 {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// CHECK-SAME: [[WORD:i[0-9]+]] noundef %n)
|
||||
#[no_mangle]
|
||||
pub unsafe fn i32_add(p: *const i32, n: usize) -> *const i32 {
|
||||
// CHECK: %[[TEMP:.+]] = getelementptr inbounds{{( nuw)?}} i32, ptr %p, [[WORD]] %n
|
||||
// CHECK: %[[TEMP:.+]] = getelementptr inbounds{{( nuw)?}} {{i32|\[4 x i8\]}}, ptr %p, [[WORD]] %n
|
||||
// CHECK: ret ptr %[[TEMP]]
|
||||
p.add(n)
|
||||
}
|
||||
@@ -18,7 +18,7 @@ pub unsafe fn i32_add(p: *const i32, n: usize) -> *const i32 {
|
||||
#[no_mangle]
|
||||
pub unsafe fn i32_sub(p: *const i32, n: usize) -> *const i32 {
|
||||
// CHECK: %[[DELTA:.+]] = sub nsw [[WORD]] 0, %n
|
||||
// CHECK: %[[TEMP:.+]] = getelementptr inbounds i32, ptr %p, [[WORD]] %[[DELTA]]
|
||||
// CHECK: %[[TEMP:.+]] = getelementptr inbounds {{i32|\[4 x i8\]}}, ptr %p, [[WORD]] %[[DELTA]]
|
||||
// CHECK: ret ptr %[[TEMP]]
|
||||
p.sub(n)
|
||||
}
|
||||
@@ -27,7 +27,7 @@ pub unsafe fn i32_sub(p: *const i32, n: usize) -> *const i32 {
|
||||
// CHECK-SAME: [[WORD:i[0-9]+]] noundef %d)
|
||||
#[no_mangle]
|
||||
pub unsafe fn i32_offset(p: *const i32, d: isize) -> *const i32 {
|
||||
// CHECK: %[[TEMP:.+]] = getelementptr inbounds i32, ptr %p, [[WORD]] %d
|
||||
// CHECK: %[[TEMP:.+]] = getelementptr inbounds {{i32|\[4 x i8\]}}, ptr %p, [[WORD]] %d
|
||||
// CHECK: ret ptr %[[TEMP]]
|
||||
p.offset(d)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ pub fn slice_iter_next_back<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'
|
||||
#[no_mangle]
|
||||
pub fn slice_iter_new(slice: &[u32]) -> std::slice::Iter<'_, u32> {
|
||||
// CHECK-NOT: slice
|
||||
// CHECK: %[[END:.+]] = getelementptr inbounds{{( nuw)?}} i32{{.+}} %slice.0{{.+}} %slice.1
|
||||
// CHECK: %[[END:.+]] = getelementptr inbounds{{( nuw)?}} {{i32|\[4 x i8\]}}{{.+}} %slice.0{{.+}} %slice.1
|
||||
// CHECK-NOT: slice
|
||||
// CHECK: insertvalue {{.+}} ptr %slice.0, 0
|
||||
// CHECK-NOT: slice
|
||||
@@ -70,7 +70,7 @@ pub fn slice_iter_new(slice: &[u32]) -> std::slice::Iter<'_, u32> {
|
||||
#[no_mangle]
|
||||
pub fn slice_iter_mut_new(slice: &mut [u32]) -> std::slice::IterMut<'_, u32> {
|
||||
// CHECK-NOT: slice
|
||||
// CHECK: %[[END:.+]] = getelementptr inbounds{{( nuw)?}} i32{{.+}} %slice.0{{.+}} %slice.1
|
||||
// CHECK: %[[END:.+]] = getelementptr inbounds{{( nuw)?}} {{i32|\[4 x i8\]}}{{.+}} %slice.0{{.+}} %slice.1
|
||||
// CHECK-NOT: slice
|
||||
// CHECK: insertvalue {{.+}} ptr %slice.0, 0
|
||||
// CHECK-NOT: slice
|
||||
|
||||
Reference in New Issue
Block a user