Skip to content

Commit

Permalink
Auto merge of rust-lang#136758 - workingjubilee:specify-opt-level-for…
Browse files Browse the repository at this point in the history
…-tests, r=<try>

tests: `-Copt-level=3` instead of `-O` in assembly tests

An effective blocker for rust-lang#135439

r? `@ghost`

try-job: test-various
try-job: aarch64-gnu
try-job: aarch64-gnu-debug
try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-mingw
try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
  • Loading branch information
bors committed Feb 9, 2025
2 parents 43ca9d1 + 984605d commit d0a1bf8
Show file tree
Hide file tree
Showing 27 changed files with 83 additions and 67 deletions.
4 changes: 2 additions & 2 deletions tests/assembly/asm/aarch64-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ add-core-stubs
//@ assembly-output: emit-asm
//@ compile-flags: -O -C panic=abort
//@ compile-flags: -Copt-level=3 -C panic=abort
//@ compile-flags: --target aarch64-unknown-linux-gnu
//@ compile-flags: -Zmerge-functions=disabled
//@ needs-llvm-components: aarch64
Expand All @@ -15,7 +15,7 @@ use minicore::*;

macro_rules! check {
($func:ident $reg:ident $code:literal) => {
// -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0
// -Copt-level=3 and extern "C" guarantee that the selected register is always r0/s0/d0/q0
#[no_mangle]
pub unsafe extern "C" fn $func() -> i32 {
let y;
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/asm/aarch64-outline-atomics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ assembly-output: emit-asm
//@ compile-flags: -O
//@ compile-flags: -Copt-level=3
//@ compile-flags: --target aarch64-unknown-linux-gnu
//@ needs-llvm-components: aarch64
//@ only-aarch64
Expand Down
4 changes: 2 additions & 2 deletions tests/assembly/asm/arm-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ add-core-stubs
//@ assembly-output: emit-asm
//@ compile-flags: -O -C panic=abort
//@ compile-flags: -Copt-level=3 -C panic=abort
//@ compile-flags: --target armv7-unknown-linux-gnueabihf
//@ compile-flags: -C target-feature=+neon
//@ compile-flags: -Zmerge-functions=disabled
Expand All @@ -21,7 +21,7 @@ impl Copy for f32x4 {}

macro_rules! check {
($func:ident $modifier:literal $reg:ident $ty:ident $mov:literal) => {
// -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0
// -Copt-level=3 and extern "C" guarantee that the selected register is always r0/s0/d0/q0
#[no_mangle]
pub unsafe extern "C" fn $func() -> $ty {
let y;
Expand Down
4 changes: 2 additions & 2 deletions tests/assembly/asm/x86-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ add-core-stubs
//@ revisions: x86_64 i686
//@ assembly-output: emit-asm
//@ compile-flags: -O -C panic=abort
//@ compile-flags: -Copt-level=3 -C panic=abort
//@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
//@[x86_64] needs-llvm-components: x86
//@[i686] compile-flags: --target i686-unknown-linux-gnu
Expand All @@ -20,7 +20,7 @@ use minicore::*;

macro_rules! check {
($func:ident $modifier:literal $reg:ident $mov:literal) => {
// -O and extern "C" guarantee that the selected register is always ax/xmm0
// -Copt-level=3 and extern "C" guarantee that the selected register is always ax/xmm0
#[no_mangle]
pub unsafe extern "C" fn $func() -> i32 {
let y;
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/libs/issue-115339-zip-arrays.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ assembly-output: emit-asm
// # zen3 previously exhibited odd vectorization
//@ compile-flags: --crate-type=lib -Ctarget-cpu=znver3 -O
//@ compile-flags: --crate-type=lib -Ctarget-cpu=znver3 -Copt-level=3
//@ only-x86_64
//@ ignore-sgx

Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/manual-eq-efficient.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Regression test for #106269
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel
//@ only-x86_64
//@ ignore-sgx

Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/panic-no-unwind-no-uwtable.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ assembly-output: emit-asm
//@ only-x86_64-unknown-linux-gnu
//@ compile-flags: -C panic=unwind -C force-unwind-tables=n -O
//@ compile-flags: -C panic=unwind -C force-unwind-tables=n -Copt-level=3

#![crate_type = "lib"]

Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/powerpc64-struct-abi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ revisions: elfv1-be elfv2-be elfv2-le aix
//@ assembly-output: emit-asm
//@ compile-flags: -O
//@ compile-flags: -Copt-level=3
//@[elfv1-be] compile-flags: --target powerpc64-unknown-linux-gnu
//@[elfv1-be] needs-llvm-components: powerpc
//@[elfv2-be] compile-flags: --target powerpc64-unknown-linux-musl
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/s390x-backchain-toggle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ revisions: enable-backchain disable-backchain
//@ assembly-output: emit-asm
//@ compile-flags: -O --crate-type=lib --target=s390x-unknown-linux-gnu
//@ compile-flags: -Copt-level=3 --crate-type=lib --target=s390x-unknown-linux-gnu
//@ needs-llvm-components: systemz
//@[enable-backchain] compile-flags: -Ctarget-feature=+backchain
//@[disable-backchain] compile-flags: -Ctarget-feature=-backchain
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/s390x-vector-abi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ revisions: z10 z10_vector z13 z13_no_vector
// ignore-tidy-linelength
//@ assembly-output: emit-asm
//@ compile-flags: -O -Z merge-functions=disabled
//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled
//@[z10] compile-flags: --target s390x-unknown-linux-gnu --cfg no_vector
//@[z10] needs-llvm-components: systemz
//@[z10_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/simd-bitmask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu
//@ [aarch64] needs-llvm-components: aarch64
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C panic=abort
//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort

#![feature(no_core, lang_items, repr_simd, intrinsics)]
#![no_core]
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/simd-intrinsic-gather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq
//@ [x86-avx512] needs-llvm-components: x86
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C panic=abort
//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort

#![feature(no_core, lang_items, repr_simd, intrinsics)]
#![no_core]
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/simd-intrinsic-mask-load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq
//@ [x86-avx512] needs-llvm-components: x86
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C panic=abort
//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort

#![feature(no_core, lang_items, repr_simd, intrinsics)]
#![no_core]
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/simd-intrinsic-mask-reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu
//@ [aarch64] needs-llvm-components: aarch64
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C panic=abort
//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort

#![feature(no_core, lang_items, repr_simd, intrinsics)]
#![no_core]
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/simd-intrinsic-mask-store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq
//@ [x86-avx512] needs-llvm-components: x86
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C panic=abort
//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort

#![feature(no_core, lang_items, repr_simd, intrinsics)]
#![no_core]
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/simd-intrinsic-scatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq
//@ [x86-avx512] needs-llvm-components: x86
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C panic=abort
//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort

#![feature(no_core, lang_items, repr_simd, intrinsics)]
#![no_core]
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/simd-intrinsic-select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu
//@ [aarch64] needs-llvm-components: aarch64
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C panic=abort
//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort

#![feature(no_core, lang_items, repr_simd, intrinsics)]
#![no_core]
Expand Down
3 changes: 2 additions & 1 deletion tests/assembly/simd/reduce-fadd-unordered.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ revisions: x86_64 aarch64
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O
//@ compile-flags: --crate-type=lib -Copt-level=3

//@[aarch64] only-aarch64
//@[x86_64] only-x86_64
//@[x86_64] compile-flags: -Ctarget-feature=+sse3
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/slice-is_ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@ [WIN] only-windows
//@ [LIN] only-linux
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel
//@ only-x86_64
//@ ignore-sgx

Expand Down
43 changes: 26 additions & 17 deletions tests/assembly/x86-return-float.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
//@ assembly-output: emit-asm
//@ only-x86
// FIXME(#114479): LLVM miscompiles loading and storing `f32` and `f64` when SSE is disabled.
// There's no compiletest directive to ignore a test on i586 only, so just always explicitly enable
// SSE2.
// Use the same target CPU as `i686` so that LLVM orders the instructions in the same order.
//@ compile-flags: -Ctarget-feature=+sse2 -Ctarget-cpu=pentium4
// Force frame pointers to make ASM more consistent between targets
//@ compile-flags: -O -C force-frame-pointers
//@ compile-flags: -C force-frame-pointers
// At opt-level=3, LLVM can merge two movss into one movsd, and we aren't testing for that.
//@ compile-flags: -Copt-level=2
//@ filecheck-flags: --implicit-check-not fld --implicit-check-not fst
//@ revisions: normal win
//@[normal] ignore-windows
//@[win] only-windows
//@ revisions: linux win
//@ add-core-stubs
//@[linux] needs-llvm-components: x86
//@[win] needs-llvm-components: x86
//@[linux] compile-flags: --target i686-unknown-linux-gnu
//@[win] compile-flags: --target i686-pc-windows-msvc

#![crate_type = "lib"]
#![feature(f16, f128)]
#![feature(no_core)]
#![no_core]

extern crate minicore;
use minicore::*;

// Tests that returning `f32` and `f64` with the "Rust" ABI on 32-bit x86 doesn't use the x87
// floating point stack, as loading and storing `f32`s and `f64`s to and from the x87 stack quietens
Expand Down Expand Up @@ -190,8 +199,8 @@ pub unsafe fn call_f64_f64(x: &mut (f64, f64)) {
}
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
// CHECK: calll {{()|_}}get_f64_f64
// normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// normal-NEXT: movsd [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
// linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// linux-NEXT: movsd [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
// win: movsd (%esp), %[[VAL1:.*]]
// win-NEXT: movsd 8(%esp), %[[VAL2:.*]]
// CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]])
Expand All @@ -207,12 +216,12 @@ pub unsafe fn call_f32_f64(x: &mut (f32, f64)) {
}
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
// CHECK: calll {{()|_}}get_f32_f64
// normal: movss [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// normal-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]]
// linux: movss [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// linux-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]]
// win: movss (%esp), %[[VAL1:.*]]
// win-NEXT: movsd 8(%esp), %[[VAL2:.*]]
// CHECK-NEXT: movss %[[VAL1]], (%[[PTR]])
// normal-NEXT: movsd %[[VAL2]], 4(%[[PTR]])
// linux-NEXT: movsd %[[VAL2]], 4(%[[PTR]])
// win-NEXT: movsd %[[VAL2]], 8(%[[PTR]])
*x = get_f32_f64();
}
Expand All @@ -225,8 +234,8 @@ pub unsafe fn call_f64_f32(x: &mut (f64, f32)) {
}
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
// CHECK: calll {{()|_}}get_f64_f32
// normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// normal-NEXT: movss [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
// linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// linux-NEXT: movss [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
// win: movsd (%esp), %[[VAL1:.*]]
// win-NEXT: movss 8(%esp), %[[VAL2:.*]]
// CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]])
Expand Down Expand Up @@ -257,8 +266,8 @@ pub unsafe fn call_f64_other(x: &mut (f64, usize)) {
}
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
// CHECK: calll {{()|_}}get_f64_other
// normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// normal-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
// linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// linux-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]]
// win: movsd (%esp), %[[VAL1:.*]]
// win-NEXT: movl 8(%esp), %[[VAL2:.*]]
// CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]])
Expand Down Expand Up @@ -289,12 +298,12 @@ pub unsafe fn call_other_f64(x: &mut (usize, f64)) {
}
// CHECK: movl {{.*}}(%ebp), %[[PTR:.*]]
// CHECK: calll {{()|_}}get_other_f64
// normal: movl [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// normal-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]]
// linux: movl [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]]
// linux-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]]
// win: movl (%esp), %[[VAL1:.*]]
// win-NEXT: movsd 8(%esp), %[[VAL2:.*]]
// CHECK-NEXT: movl %[[VAL1]], (%[[PTR]])
// normal-NEXT: movsd %[[VAL2]], 4(%[[PTR]])
// linux-NEXT: movsd %[[VAL2]], 4(%[[PTR]])
// win-NEXT: movsd %[[VAL2]], 8(%[[PTR]])
*x = get_other_f64();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/x86_64-array-pair-load-store-merge.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel
//@ only-x86_64
//@ ignore-sgx
//@ ignore-apple (manipulates rsp too)
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/x86_64-bigint-helpers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ only-x86_64
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -O -C target-cpu=x86-64-v4
//@ compile-flags: --crate-type=lib -Copt-level=3 -C target-cpu=x86-64-v4
//@ compile-flags: -C llvm-args=-x86-asm-syntax=intel
//@ revisions: llvm-pre-20 llvm-20
//@ [llvm-20] min-llvm-version: 20
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/x86_64-floating-point-clamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//@ assembly-output: emit-asm
// Set the base cpu explicitly, in case the default has been changed.
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel -C target-cpu=x86-64
//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel -C target-cpu=x86-64
//@ only-x86_64
//@ ignore-sgx

Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/x86_64-function-return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//@ revisions: unset keep thunk-extern keep-thunk-extern thunk-extern-keep
//@ assembly-output: emit-asm
//@ compile-flags: -O
//@ compile-flags: -Copt-level=3
//@ [keep] compile-flags: -Zfunction-return=keep
//@ [thunk-extern] compile-flags: -Zfunction-return=thunk-extern
//@ [keep-thunk-extern] compile-flags: -Zfunction-return=keep -Zfunction-return=thunk-extern
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/x86_64-no-jump-tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//@ revisions: unset set
//@ assembly-output: emit-asm
//@ compile-flags: -O
//@ compile-flags: -Copt-level=3
//@ [set] compile-flags: -Zno-jump-tables
//@ only-x86_64
//@ ignore-sgx
Expand Down
Loading

0 comments on commit d0a1bf8

Please sign in to comment.