Skip to content

Commit

Permalink
Amend codegen test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jul 1, 2022
1 parent a3e1a2b commit cbbf06b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/test/codegen/issue-37945.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn is_empty_1(xs: Iter<f32>) -> bool {
// CHECK-NEXT: start:
// CHECK-NEXT: [[A:%.*]] = icmp ne {{i32\*|ptr}} %xs.1, null
// CHECK-NEXT: tail call void @llvm.assume(i1 [[A]])
// CHECK-NEXT: [[B:%.*]] = icmp eq {{i32\*|ptr}} %xs.0, %xs.1
// CHECK-NEXT: [[B:%.*]] = icmp eq {{i32\*|ptr}} %xs.1, %xs.0
// CHECK-NEXT: ret i1 [[B:%.*]]
{xs}.next().is_none()
}
Expand All @@ -28,7 +28,7 @@ pub fn is_empty_2(xs: Iter<f32>) -> bool {
// CHECK-NEXT: start:
// CHECK-NEXT: [[C:%.*]] = icmp ne {{i32\*|ptr}} %xs.1, null
// CHECK-NEXT: tail call void @llvm.assume(i1 [[C]])
// CHECK-NEXT: [[D:%.*]] = icmp eq {{i32\*|ptr}} %xs.0, %xs.1
// CHECK-NEXT: [[D:%.*]] = icmp eq {{i32\*|ptr}} %xs.1, %xs.0
// CHECK-NEXT: ret i1 [[D:%.*]]
xs.map(|&x| x).next().is_none()
}
2 changes: 1 addition & 1 deletion src/test/codegen/issue-75659.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test checks that the call to memchr/slice_contains is optimized away
// when searching in small slices.

// compile-flags: -O
// compile-flags: -O -Zinline-mir=no
// only-x86_64

#![crate_type = "lib"]
Expand Down
12 changes: 5 additions & 7 deletions src/test/codegen/mem-replace-direct-memcpy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// may e.g. multiply `size_of::<T>()` with a variable "count" (which is only
// known to be `1` after inlining).

// compile-flags: -C no-prepopulate-passes
// compile-flags: -C no-prepopulate-passes -Zinline-mir=no

#![crate_type = "lib"]

Expand All @@ -12,14 +12,12 @@ pub fn replace_byte(dst: &mut u8, src: u8) -> u8 {
}

// NOTE(eddyb) the `CHECK-NOT`s ensure that the only calls of `@llvm.memcpy` in
// the entire output, are the two direct calls we want, from `ptr::{read,write}`.
// the entire output, are the two direct calls we want, from `ptr::replace`.

// CHECK-NOT: call void @llvm.memcpy
// CHECK: ; core::ptr::read
// CHECK: ; core::mem::replace
// CHECK-NOT: call void @llvm.memcpy
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %src, i{{.*}} 1, i1 false)
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %dest, i{{.*}} 1, i1 false)
// CHECK-NOT: call void @llvm.memcpy
// CHECK: ; core::ptr::write
// CHECK-NOT: call void @llvm.memcpy
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %dst, {{i8\*|ptr}} align 1 %src, i{{.*}} 1, i1 false)
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %dest, {{i8\*|ptr}} align 1 %src{{.*}}, i{{.*}} 1, i1 false)
// CHECK-NOT: call void @llvm.memcpy
2 changes: 1 addition & 1 deletion src/test/codegen/remap_path_prefix/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ignore-windows
//

// compile-flags: -g -C no-prepopulate-passes --remap-path-prefix={{cwd}}=/the/cwd --remap-path-prefix={{src-base}}=/the/src
// compile-flags: -g -C no-prepopulate-passes --remap-path-prefix={{cwd}}=/the/cwd --remap-path-prefix={{src-base}}=/the/src -Zinline-mir=no
// aux-build:remap_path_prefix_aux.rs

extern crate remap_path_prefix_aux;
Expand Down
7 changes: 4 additions & 3 deletions src/test/codegen/simd-wide-sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ pub fn wider_reduce_iter(x: Simd<u8, N>) -> u16 {
#[no_mangle]
// CHECK-LABEL: @wider_reduce_into_iter
pub fn wider_reduce_into_iter(x: Simd<u8, N>) -> u16 {
// CHECK: zext <8 x i8>
// CHECK-SAME: to <8 x i16>
// CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
// FIXME MIR inlining messes up LLVM optimizations.
// WOULD-CHECK: zext <8 x i8>
// WOULD-CHECK-SAME: to <8 x i16>
// WOULD-CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
x.to_array().into_iter().map(u16::from).sum()
}
2 changes: 1 addition & 1 deletion src/test/codegen/slice-ref-equality.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// compile-flags: -C opt-level=3
// compile-flags: -C opt-level=3 -Zmerge-functions=disabled

#![crate_type = "lib"]

Expand Down
7 changes: 4 additions & 3 deletions src/test/codegen/swap-small-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ type RGB48 = [u16; 3];
// CHECK-LABEL: @swap_rgb48
#[no_mangle]
pub fn swap_rgb48(x: &mut RGB48, y: &mut RGB48) {
// CHECK-NOT: alloca
// CHECK: load i48
// CHECK: store i48
// FIXME MIR inlining messes up LLVM optimizations.
// WOULD-CHECK-NOT: alloca
// WOULD-CHECK: load i48
// WOULD-CHECK: store i48
swap(x, y)
}

Expand Down
10 changes: 6 additions & 4 deletions src/test/codegen/vec-in-place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ pub fn vec_iterator_cast_unwrap(vec: Vec<Wrapper<u8>>) -> Vec<u8> {
// CHECK-LABEL: @vec_iterator_cast_aggregate
#[no_mangle]
pub fn vec_iterator_cast_aggregate(vec: Vec<[u64; 4]>) -> Vec<Foo> {
// CHECK-NOT: loop
// CHECK-NOT: call
// FIXME These checks should be the same as other functions.
// CHECK-NOT: @__rust_alloc
// CHECK-NOT: @__rust_alloc
vec.into_iter().map(|e| unsafe { std::mem::transmute(e) }).collect()
}

// CHECK-LABEL: @vec_iterator_cast_deaggregate
#[no_mangle]
pub fn vec_iterator_cast_deaggregate(vec: Vec<Bar>) -> Vec<[u64; 4]> {
// CHECK-NOT: loop
// CHECK-NOT: call
// FIXME These checks should be the same as other functions.
// CHECK-NOT: @__rust_alloc
// CHECK-NOT: @__rust_alloc

// Safety: For the purpose of this test we assume that Bar layout matches [u64; 4].
// This currently is not guaranteed for repr(Rust) types, but it happens to work here and
Expand Down

3 comments on commit cbbf06b

@krasimirgg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over at our experimental rust + llvm@HEAD build bot, we've started seeing failures of src/test/codegen/issue-37945, which appear to be caused by the changes to src/test/codegen/issue-37945.rs from this commit:
https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/11680#0181bf6e-369d-4310-9751-cd09112fc3aa/633-650

/var/lib/buildkite-agent/builds/rust-llvm-integrate/llvm-project/rust-llvm-integrate-prototype/src/test/codegen/issue-37945.rs:20:16: error: CHECK-NEXT: expected string not found in input
--
  | // CHECK-NEXT: [[B:%.*]] = icmp eq {{i32\*\|ptr}} %xs.1, %xs.0
  | ^
  | /var/lib/buildkite-agent/builds/rust-llvm-integrate/llvm-project/rust-llvm-integrate-prototype/build/x86_64-unknown-linux-gnu/test/codegen/issue-37945/issue-37945.ll:10:36: note: scanning from here
  | tail call void @llvm.assume(i1 %0)
  | ^
  | /var/lib/buildkite-agent/builds/rust-llvm-integrate/llvm-project/rust-llvm-integrate-prototype/build/x86_64-unknown-linux-gnu/test/codegen/issue-37945/issue-37945.ll:11:4: note: possible intended match here
  | %_12.i = icmp eq ptr %xs.0, %xs.1
  | ^
  | /var/lib/buildkite-agent/builds/rust-llvm-integrate/llvm-project/rust-llvm-integrate-prototype/src/test/codegen/issue-37945.rs:31:16: error: CHECK-NEXT: expected string not found in input
  | // CHECK-NEXT: [[D:%.*]] = icmp eq {{i32\*\|ptr}} %xs.1, %xs.0
  | ^
  | /var/lib/buildkite-agent/builds/rust-llvm-integrate/llvm-project/rust-llvm-integrate-prototype/build/x86_64-unknown-linux-gnu/test/codegen/issue-37945/issue-37945.ll:19:36: note: scanning from here
  | tail call void @llvm.assume(i1 %0)
  | ^
  | /var/lib/buildkite-agent/builds/rust-llvm-integrate/llvm-project/rust-llvm-integrate-prototype/build/x86_64-unknown-linux-gnu/test/codegen/issue-37945/issue-37945.ll:20:4: note: possible intended match here
  | %_12.i = icmp eq ptr %xs.0, %xs.1
  | ^
  |  
  | Input file: /var/lib/buildkite-agent/builds/rust-llvm-integrate/llvm-project/rust-llvm-integrate-prototype/build/x86_64-unknown-linux-gnu/test/codegen/issue-37945/issue-37945.ll
  | Check file: /var/lib/buildkite-agent/builds/rust-llvm-integrate/llvm-project/rust-llvm-integrate-prototype/src/test/codegen/issue-37945.rs
  |  
  | -dump-input=help explains the following input dump.
  |  
  | Input was:
  | <<<<<<
  | .
  | .
  | .
  | 5:
  | 6: ; Function Attrs: mustprogress nofree nosync nounwind nonlazybind willreturn uwtable
  | 7: define noundef zeroext i1 @is_empty_1(ptr noundef nonnull %xs.0, ptr %xs.1) unnamed_addr #0 {
  | 8: start:
  | 9:  %0 = icmp ne ptr %xs.1, null
  | 10:  tail call void @llvm.assume(i1 %0)
  | next:20'0                                        X error: no match found
  | 11:  %_12.i = icmp eq ptr %xs.0, %xs.1
  | next:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  | next:20'1        ?                                possible intended match
  | 12:  ret i1 %_12.i
  | next:20'0     ~~~~~~~~~~~~~~~
  | 13: }
  | next:20'0     ~~
  | 14:
  | next:20'0     ~
  | 15: ; Function Attrs: mustprogress nofree nosync nounwind nonlazybind willreturn uwtable
  | next:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  | 16: define noundef zeroext i1 @is_empty_2(ptr noundef nonnull %xs.0, ptr %xs.1) unnamed_addr #0 {
  | next:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  | 17: start:
  | 18:  %0 = icmp ne ptr %xs.1, null
  | 19:  tail call void @llvm.assume(i1 %0)
  | next:31'0                                        X error: no match found
  | 20:  %_12.i = icmp eq ptr %xs.0, %xs.1
  | next:31'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  | next:31'1        ?                                possible intended match
  | 21:  ret i1 %_12.i
  | next:31'0     ~~~~~~~~~~~~~~~
  | 22: }
  | next:31'0     ~~
  | 23:
  | next:31'0     ~
  | 24: ; Function Attrs: inaccessiblememonly mustprogress nocallback nofree nosync nounwind willreturn
  | next:31'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  | 25: declare void @llvm.assume(i1 noundef) #1
  | next:31'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  | .
  | .
  | .
  | >>>>>>
  | ------------------------------------------
  |  
  |  
  |  
  | failures:
  | [codegen] src/test/codegen/issue-37945.rs

AFAIK, the old version of this test case was running successfully. I must be missing some context about this -- did something change in rust or is there a new rust-specific llvm patch that requires these changes? Anyways, any help and suggestions to update this so it also works with llvm@HEAD would be great!

@nikic
Copy link
Contributor

@nikic nikic commented on cbbf06b Jul 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of operands doesn't matter, so you can use something like %xs.{{0|1}} to allow both.

@krasimirgg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! #98920

Please sign in to comment.