diff --git a/tests/assembly/issue-83585-small-pod-struct-equality.rs b/tests/assembly/issue-83585-small-pod-struct-equality.rs index 56d458d851436..9b0d605666d6e 100644 --- a/tests/assembly/issue-83585-small-pod-struct-equality.rs +++ b/tests/assembly/issue-83585-small-pod-struct-equality.rs @@ -4,27 +4,25 @@ #![crate_type = "lib"] -#[no_mangle] type T = u8; type T1 = (T, T, T, T, T, T, T, T); type T2 = [T; 8]; -#[no_mangle] // CHECK-LABEL: foo1a // CHECK: cmp -// CHECK-NEXT: set +// CHECK-NEXT: sete // CHECK-NEXT: ret +#[no_mangle] pub fn foo1a(a: T1, b: T1) -> bool { a == b } -#[no_mangle] // CHECK-LABEL: foo1b // CHECK: mov // CHECK-NEXT: cmp -// CHECK-NEXT: set +// CHECK-NEXT: sete // CHECK-NEXT: ret +#[no_mangle] pub fn foo1b(a: &T1, b: &T1) -> bool { a == b } - diff --git a/tests/codegen/issues/issue-109328-split_first.rs b/tests/codegen/issues/issue-109328-split_first.rs index a43e653e1a264..d3844c3ec20cc 100644 --- a/tests/codegen/issues/issue-109328-split_first.rs +++ b/tests/codegen/issues/issue-109328-split_first.rs @@ -1,11 +1,10 @@ //@ compile-flags: -O -//@ min-llvm-version: 17 #![crate_type = "lib"] -#[no_mangle] // CHECK-LABEL: @foo -// CHECK: getelementptr inbounds +// CHECK-NEXT: {{.*}}: +// CHECK-NEXT: getelementptr inbounds // CHECK-NEXT: load i64 // CHECK-NEXT: icmp eq i64 // CHECK-NEXT: br i1 diff --git a/tests/codegen/issues/issue-110797-enum-jump-same.rs b/tests/codegen/issues/issue-110797-enum-jump-same.rs index bfd10c0a5820d..d52faef23ad8d 100644 --- a/tests/codegen/issues/issue-110797-enum-jump-same.rs +++ b/tests/codegen/issues/issue-110797-enum-jump-same.rs @@ -1,27 +1,26 @@ //@ compile-flags: -O -// XXX: The x86-64 assembly get optimized correclty. But llvm-ir output is not until llvm 18? //@ min-llvm-version: 18 #![crate_type = "lib"] -pub enum K{ +pub enum K { A(Box<[i32]>), B(Box<[u8]>), C(Box<[String]>), D(Box<[u16]>), } -#[no_mangle] // CHECK-LABEL: @get_len -// CHECK: getelementptr inbounds +// CHECK-NEXT: {{.*}}: +// CHECK-NEXT: getelementptr inbounds // CHECK-NEXT: load // CHECK-NEXT: ret i64 -// CHECK-NOT: switch -pub fn get_len(arg: &K)->usize{ +#[no_mangle] +pub fn get_len(arg: &K) -> usize { match arg { - K::A(ref lst)=>lst.len(), - K::B(ref lst)=>lst.len(), - K::C(ref lst)=>lst.len(), - K::D(ref lst)=>lst.len(), + K::A(ref lst) => lst.len(), + K::B(ref lst) => lst.len(), + K::C(ref lst) => lst.len(), + K::D(ref lst) => lst.len(), } } diff --git a/tests/codegen/issues/issue-111508-vec-tryinto-array.rs b/tests/codegen/issues/issue-111508-vec-tryinto-array.rs index 2e7244e971307..6415724b40ad5 100644 --- a/tests/codegen/issues/issue-111508-vec-tryinto-array.rs +++ b/tests/codegen/issues/issue-111508-vec-tryinto-array.rs @@ -8,9 +8,9 @@ use std::convert::TryInto; const N: usize = 24; -#[no_mangle] // CHECK-LABEL: @example // CHECK-NOT: unwrap_failed +#[no_mangle] pub fn example(a: Vec) -> u8 { if a.len() != 32 { return 0; diff --git a/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs b/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs index fc04a6cc41abb..ae02c3fb79e72 100644 --- a/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs +++ b/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs @@ -1,17 +1,12 @@ //@ compile-flags: -O -//@ min-llvm-version: 17 #![crate_type = "lib"] // CHECK-LABEL: @write_u8_variant_a -// CHECK: getelementptr +// CHECK-NEXT: {{.*}}: +// CHECK-NEXT: getelementptr // CHECK-NEXT: icmp ugt #[no_mangle] -pub fn write_u8_variant_a( - bytes: &mut [u8], - buf: u8, - offset: usize, -) -> Option<&mut [u8]> { +pub fn write_u8_variant_a(bytes: &mut [u8], buf: u8, offset: usize) -> Option<&mut [u8]> { let buf = buf.to_le_bytes(); - bytes - .get_mut(offset..).and_then(|bytes| bytes.get_mut(..buf.len())) + bytes.get_mut(offset..).and_then(|bytes| bytes.get_mut(..buf.len())) } diff --git a/tests/codegen/issues/issue-113757-bounds-check-after-cmp-max.rs b/tests/codegen/issues/issue-113757-bounds-check-after-cmp-max.rs index 5dedefc43d114..d495adf99804c 100644 --- a/tests/codegen/issues/issue-113757-bounds-check-after-cmp-max.rs +++ b/tests/codegen/issues/issue-113757-bounds-check-after-cmp-max.rs @@ -1,15 +1,14 @@ // in Rust 1.73, -O and opt-level=3 optimizes differently //@ compile-flags: -C opt-level=3 -//@ min-llvm-version: 17 #![crate_type = "lib"] use std::cmp::max; -#[no_mangle] // CHECK-LABEL: @foo // CHECK-NOT: slice_start_index_len_fail // CHECK-NOT: unreachable -pub fn foo(v: &mut Vec, size: usize)-> Option<&mut [u8]> { +#[no_mangle] +pub fn foo(v: &mut Vec, size: usize) -> Option<&mut [u8]> { if v.len() > max(1, size) { let start = v.len() - size; Some(&mut v[start..]) diff --git a/tests/codegen/issues/issue-36010-some-box-is_some.rs b/tests/codegen/issues/issue-36010-some-box-is_some.rs index b7179987e7d01..44c01096f15ae 100644 --- a/tests/codegen/issues/issue-36010-some-box-is_some.rs +++ b/tests/codegen/issues/issue-36010-some-box-is_some.rs @@ -8,12 +8,12 @@ fn foo(a: &mut T, b: T) -> bool { let b = Some(mem::replace(a, b)); let ret = b.is_some(); mem::forget(b); - return ret + return ret; } // CHECK-LABEL: @foo_u32 // CHECK: store i32 -// CHECK-NEXT: ret i1 +// CHECK-NEXT: ret i1 true #[no_mangle] pub fn foo_u32(a: &mut u32, b: u32) -> bool { foo(a, b) @@ -21,9 +21,8 @@ pub fn foo_u32(a: &mut u32, b: u32) -> bool { // CHECK-LABEL: @foo_box // CHECK: store ptr -// CHECK-NEXT: ret i1 +// CHECK-NEXT: ret i1 true #[no_mangle] pub fn foo_box(a: &mut Box, b: Box) -> bool { foo(a, b) } - diff --git a/tests/codegen/issues/issue-68667-unwrap-combinators.rs b/tests/codegen/issues/issue-68667-unwrap-combinators.rs index 05760dc9b5566..6bd4c566a0c28 100644 --- a/tests/codegen/issues/issue-68667-unwrap-combinators.rs +++ b/tests/codegen/issues/issue-68667-unwrap-combinators.rs @@ -11,7 +11,5 @@ // CHECK-NEXT: ret i1 #[no_mangle] pub fn unwrap_combinators(a: Option, b: i32) -> bool { - a.map(|t| t >= b) - .unwrap_or(false) + a.map(|t| t >= b).unwrap_or(false) } - diff --git a/tests/codegen/issues/issue-74938-array-split-at.rs b/tests/codegen/issues/issue-74938-array-split-at.rs index 1f8aa3868d75f..2675e404ced3b 100644 --- a/tests/codegen/issues/issue-74938-array-split-at.rs +++ b/tests/codegen/issues/issue-74938-array-split-at.rs @@ -5,11 +5,10 @@ const N: usize = 3; pub type T = u8; -#[no_mangle] -// CHECK-LABEL: @split_mutiple +// CHECK-LABEL: @split_multiple // CHECK-NOT: unreachable -pub fn split_mutiple(slice: &[T]) -> (&[T], &[T]) { +#[no_mangle] +pub fn split_multiple(slice: &[T]) -> (&[T], &[T]) { let len = slice.len() / N; slice.split_at(len * N) } - diff --git a/tests/codegen/issues/issue-93036-assert-index.rs b/tests/codegen/issues/issue-93036-assert-index.rs index 9e4437cc65616..7a2ea08726688 100644 --- a/tests/codegen/issues/issue-93036-assert-index.rs +++ b/tests/codegen/issues/issue-93036-assert-index.rs @@ -1,12 +1,9 @@ //@ compile-flags: -O -//@ min-llvm-version: 17 #![crate_type = "lib"] #[no_mangle] // CHECK-LABEL: @foo -// CHECK: {{.*}}: -// CHECK: ret // CHECK-NOT: unreachable pub fn foo(arr: &mut [u32]) { for i in 0..arr.len() { @@ -15,4 +12,3 @@ pub fn foo(arr: &mut [u32]) { } } } - diff --git a/tests/codegen/slice-pointer-nonnull-unwrap.rs b/tests/codegen/slice-pointer-nonnull-unwrap.rs index 51ea4a1f943d6..48bf8fa88a06d 100644 --- a/tests/codegen/slice-pointer-nonnull-unwrap.rs +++ b/tests/codegen/slice-pointer-nonnull-unwrap.rs @@ -5,15 +5,15 @@ use std::ptr::NonNull; // CHECK-LABEL: @slice_ptr_len_1 -// CHECK: {{.*}}: +// CHECK-NEXT: {{.*}}: // CHECK-NEXT: ret i64 %ptr.1 #[no_mangle] pub fn slice_ptr_len_1(ptr: *const [u8]) -> usize { - let ptr = ptr.cast_mut(); - if let Some(ptr) = NonNull::new(ptr) { - ptr.len() - } else { - // We know ptr is null, so we know ptr.wrapping_byte_add(1) is not null. - NonNull::new(ptr.wrapping_byte_add(1)).unwrap().len() - } + let ptr = ptr.cast_mut(); + if let Some(ptr) = NonNull::new(ptr) { + ptr.len() + } else { + // We know ptr is null, so we know ptr.wrapping_byte_add(1) is not null. + NonNull::new(ptr.wrapping_byte_add(1)).unwrap().len() + } }