From 7453128b676d68abf6003c6d1e0d1055799eebb1 Mon Sep 17 00:00:00 2001 From: Rajveer Date: Fri, 23 Aug 2024 18:33:59 +0530 Subject: [PATCH] [testsuite][cleanup] Remove all usages of `dont_merge` hack to avoid function merging Resolves #129438 The `-Zmerge-functions=disabled` compile flag exists for this purpose. --- tests/assembly/asm/aarch64-modifiers.rs | 7 +------ tests/assembly/asm/aarch64-types.rs | 14 ++------------ tests/assembly/asm/arm-modifiers.rs | 7 +------ tests/assembly/asm/arm-types.rs | 13 +------------ tests/assembly/asm/hexagon-types.rs | 25 +------------------------ tests/assembly/asm/loongarch-type.rs | 10 +--------- tests/assembly/asm/mips-types.rs | 11 ++--------- tests/assembly/asm/powerpc-types.rs | 11 ++--------- tests/assembly/asm/riscv-types.rs | 18 ++++++------------ tests/assembly/asm/s390x-types.rs | 10 +--------- tests/assembly/asm/x86-modifiers.rs | 9 +++------ tests/assembly/asm/x86-types.rs | 14 ++------------ 12 files changed, 23 insertions(+), 126 deletions(-) diff --git a/tests/assembly/asm/aarch64-modifiers.rs b/tests/assembly/asm/aarch64-modifiers.rs index b7ef1d77ea023..a4a41dd96c169 100644 --- a/tests/assembly/asm/aarch64-modifiers.rs +++ b/tests/assembly/asm/aarch64-modifiers.rs @@ -1,6 +1,7 @@ //@ assembly-output: emit-asm //@ compile-flags: -O -C panic=abort //@ compile-flags: --target aarch64-unknown-linux-gnu +//@ compile-flags: -Zmerge-functions=disabled //@ needs-llvm-components: aarch64 #![feature(no_core, lang_items, rustc_attrs)] @@ -29,12 +30,6 @@ macro_rules! check { // -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0 #[no_mangle] pub unsafe extern "C" fn $func() -> i32 { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!($code, out($reg) y); y diff --git a/tests/assembly/asm/aarch64-types.rs b/tests/assembly/asm/aarch64-types.rs index 3e2a4773703a3..6e7e4fe9b464a 100644 --- a/tests/assembly/asm/aarch64-types.rs +++ b/tests/assembly/asm/aarch64-types.rs @@ -2,7 +2,9 @@ //@ assembly-output: emit-asm //@ [aarch64] compile-flags: --target aarch64-unknown-linux-gnu //@ [aarch64] needs-llvm-components: aarch64 +//@ [aarch64] compile-flags: -Zmerge-functions=disabled //@ [arm64ec] compile-flags: --target arm64ec-pc-windows-msvc +//@ [arm64ec] compile-flags: -Zmerge-functions=disabled //@ [arm64ec] needs-llvm-components: aarch64 #![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] @@ -113,12 +115,6 @@ macro_rules! check { ($func:ident $ty:ident $class:ident $mov:literal $modifier:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!( concat!($mov, " {:", $modifier, "}, {:", $modifier, "}"), @@ -134,12 +130,6 @@ macro_rules! check_reg { ($func:ident $ty:ident $reg:tt $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x); y diff --git a/tests/assembly/asm/arm-modifiers.rs b/tests/assembly/asm/arm-modifiers.rs index 0674e169d72e6..d421e0e6954cc 100644 --- a/tests/assembly/asm/arm-modifiers.rs +++ b/tests/assembly/asm/arm-modifiers.rs @@ -2,6 +2,7 @@ //@ compile-flags: -O -C panic=abort //@ compile-flags: --target armv7-unknown-linux-gnueabihf //@ compile-flags: -C target-feature=+neon +//@ compile-flags: -Zmerge-functions=disabled //@ needs-llvm-components: arm #![feature(no_core, lang_items, rustc_attrs, repr_simd)] @@ -40,12 +41,6 @@ macro_rules! check { // -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0 #[no_mangle] pub unsafe extern "C" fn $func() -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " {0:", $modifier, "}, {0:", $modifier, "}"), out($reg) y); y diff --git a/tests/assembly/asm/arm-types.rs b/tests/assembly/asm/arm-types.rs index eeff1a070b492..448b92aa8399a 100644 --- a/tests/assembly/asm/arm-types.rs +++ b/tests/assembly/asm/arm-types.rs @@ -2,6 +2,7 @@ //@ assembly-output: emit-asm //@ compile-flags: --target armv7-unknown-linux-gnueabihf //@ compile-flags: -C opt-level=0 +//@ compile-flags: -Zmerge-functions=disabled //@[d32] compile-flags: -C target-feature=+d32 //@[neon] compile-flags: -C target-feature=+neon --cfg d32 //@[neon] filecheck-flags: --check-prefix d32 @@ -114,12 +115,6 @@ macro_rules! check { ($func:ident $ty:ident $class:ident $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " {}, {}"), out($class) y, in($class) x); y @@ -131,12 +126,6 @@ macro_rules! check_reg { ($func:ident $ty:ident $reg:tt $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x); y diff --git a/tests/assembly/asm/hexagon-types.rs b/tests/assembly/asm/hexagon-types.rs index 269c7582a1cee..9389fcf9cbac9 100644 --- a/tests/assembly/asm/hexagon-types.rs +++ b/tests/assembly/asm/hexagon-types.rs @@ -1,5 +1,6 @@ //@ assembly-output: emit-asm //@ compile-flags: --target hexagon-unknown-linux-musl +//@ compile-flags: -Zmerge-functions=disabled //@ needs-llvm-components: hexagon #![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] @@ -41,12 +42,6 @@ macro_rules! check { ($func:ident $ty:ident $class:ident) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!("{} = {}", out($class) y, in($class) x); y @@ -58,12 +53,6 @@ macro_rules! check_reg { ($func:ident $ty:ident $reg:tt) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($reg, " = ", $reg), lateout($reg) y, in($reg) x); y @@ -77,12 +66,6 @@ macro_rules! check_reg { // CHECK: InlineAsm End #[no_mangle] pub unsafe fn sym_static() { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - asm!("r0 = #{}", sym extern_static); } @@ -92,12 +75,6 @@ pub unsafe fn sym_static() { // CHECK: InlineAsm End #[no_mangle] pub unsafe fn sym_fn() { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - asm!("r0 = #{}", sym extern_func); } diff --git a/tests/assembly/asm/loongarch-type.rs b/tests/assembly/asm/loongarch-type.rs index e4c46cfcf81b1..1b097f4110501 100644 --- a/tests/assembly/asm/loongarch-type.rs +++ b/tests/assembly/asm/loongarch-type.rs @@ -1,5 +1,6 @@ //@ assembly-output: emit-asm //@ compile-flags: --target loongarch64-unknown-linux-gnu +//@ compile-flags: -Zmerge-functions=disabled //@ needs-llvm-components: loongarch #![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] @@ -39,11 +40,6 @@ extern "C" { static extern_static: u8; } -// Hack to avoid function merging -extern "Rust" { - fn dont_merge(s: &str); -} - // CHECK-LABEL: sym_fn: // CHECK: #APP // CHECK: pcalau12i $t0, %got_pc_hi20(extern_func) @@ -67,8 +63,6 @@ pub unsafe fn sym_static() { macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - dont_merge(stringify!($func)); - let y; asm!(concat!($mov," {}, {}"), out($class) y, in($class) x); y @@ -78,8 +72,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x); y diff --git a/tests/assembly/asm/mips-types.rs b/tests/assembly/asm/mips-types.rs index bd62f4a5236c2..4c059713e679a 100644 --- a/tests/assembly/asm/mips-types.rs +++ b/tests/assembly/asm/mips-types.rs @@ -1,8 +1,10 @@ //@ revisions: mips32 mips64 //@ assembly-output: emit-asm //@[mips32] compile-flags: --target mips-unknown-linux-gnu +//@[mips32] compile-flags: -Zmerge-functions=disabled //@[mips32] needs-llvm-components: mips //@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 +//@[mips64] compile-flags: -Zmerge-functions=disabled //@[mips64] needs-llvm-components: mips #![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] @@ -43,16 +45,9 @@ extern "C" { static extern_static: u8; } -// Hack to avoid function merging -extern "Rust" { - fn dont_merge(s: &str); -} - macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - dont_merge(stringify!($func)); - let y; asm!(concat!($mov," {}, {}"), out($class) y, in($class) x); y @@ -62,8 +57,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x); y diff --git a/tests/assembly/asm/powerpc-types.rs b/tests/assembly/asm/powerpc-types.rs index bc8af08ad1133..92603e9c34543 100644 --- a/tests/assembly/asm/powerpc-types.rs +++ b/tests/assembly/asm/powerpc-types.rs @@ -1,8 +1,10 @@ //@ revisions: powerpc powerpc64 //@ assembly-output: emit-asm //@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu +//@[powerpc] compile-flags: -Zmerge-functions=disabled //@[powerpc] needs-llvm-components: powerpc //@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu +//@[powerpc64] compile-flags: -Zmerge-functions=disabled //@[powerpc64] needs-llvm-components: powerpc #![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] @@ -43,16 +45,9 @@ extern "C" { static extern_static: u8; } -// Hack to avoid function merging -extern "Rust" { - fn dont_merge(s: &str); -} - macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - dont_merge(stringify!($func)); - let y; asm!(concat!($mov," {}, {}"), out($class) y, in($class) x); y @@ -62,8 +57,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { macro_rules! check_reg { ($func:ident, $ty:ty, $rego:tt, $regc:tt, $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " ", $rego, ", ", $rego), lateout($regc) y, in($regc) x); y diff --git a/tests/assembly/asm/riscv-types.rs b/tests/assembly/asm/riscv-types.rs index 51b3aaf99d944..fd074a073faa6 100644 --- a/tests/assembly/asm/riscv-types.rs +++ b/tests/assembly/asm/riscv-types.rs @@ -2,26 +2,32 @@ //@ assembly-output: emit-asm //@[riscv64] compile-flags: --target riscv64imac-unknown-none-elf +//@[riscv64] compile-flags: -Zmerge-functions=disabled //@[riscv64] needs-llvm-components: riscv //@[riscv32] compile-flags: --target riscv32imac-unknown-none-elf +//@[riscv32] compile-flags: -Zmerge-functions=disabled //@[riscv32] needs-llvm-components: riscv //@[riscv64-zfhmin] compile-flags: --target riscv64imac-unknown-none-elf --cfg riscv64 +//@[riscv64-zfhmin] compile-flags: -Zmerge-functions=disabled //@[riscv64-zfhmin] needs-llvm-components: riscv //@[riscv64-zfhmin] compile-flags: -C target-feature=+zfhmin //@[riscv64-zfhmin] filecheck-flags: --check-prefix riscv64 //@[riscv32-zfhmin] compile-flags: --target riscv32imac-unknown-none-elf +//@[riscv32-zfhmin] compile-flags: -Zmerge-functions=disabled //@[riscv32-zfhmin] needs-llvm-components: riscv //@[riscv32-zfhmin] compile-flags: -C target-feature=+zfhmin //@[riscv64-zfh] compile-flags: --target riscv64imac-unknown-none-elf --cfg riscv64 +//@[riscv64-zfh] compile-flags: -Zmerge-functions=disabled //@[riscv64-zfh] needs-llvm-components: riscv //@[riscv64-zfh] compile-flags: -C target-feature=+zfh //@[riscv64-zfh] filecheck-flags: --check-prefix riscv64 --check-prefix zfhmin //@[riscv32-zfh] compile-flags: --target riscv32imac-unknown-none-elf +//@[riscv32-zfh] compile-flags: -Zmerge-functions=disabled //@[riscv32-zfh] needs-llvm-components: riscv //@[riscv32-zfh] compile-flags: -C target-feature=+zfh //@[riscv32-zfh] filecheck-flags: --check-prefix zfhmin @@ -90,12 +96,6 @@ macro_rules! check { ($func:ident $ty:ident $class:ident $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " {}, {}"), out($class) y, in($class) x); y @@ -107,12 +107,6 @@ macro_rules! check_reg { ($func:ident $ty:ident $reg:tt $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x); y diff --git a/tests/assembly/asm/s390x-types.rs b/tests/assembly/asm/s390x-types.rs index 661907360bd28..2ca5b889fd562 100644 --- a/tests/assembly/asm/s390x-types.rs +++ b/tests/assembly/asm/s390x-types.rs @@ -1,6 +1,7 @@ //@ revisions: s390x //@ assembly-output: emit-asm //@[s390x] compile-flags: --target s390x-unknown-linux-gnu +//@[s390x] compile-flags: -Zmerge-functions=disabled //@[s390x] needs-llvm-components: systemz #![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] @@ -42,16 +43,9 @@ extern "C" { static extern_static: u8; } -// Hack to avoid function merging -extern "Rust" { - fn dont_merge(s: &str); -} - macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - dont_merge(stringify!($func)); - let y; asm!(concat!($mov," {}, {}"), out($class) y, in($class) x); y @@ -61,8 +55,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " %", $reg, ", %", $reg), lateout($reg) y, in($reg) x); y diff --git a/tests/assembly/asm/x86-modifiers.rs b/tests/assembly/asm/x86-modifiers.rs index c5e393b10564e..350d2aba7eeec 100644 --- a/tests/assembly/asm/x86-modifiers.rs +++ b/tests/assembly/asm/x86-modifiers.rs @@ -1,9 +1,12 @@ //@ revisions: x86_64 i686 //@ assembly-output: emit-asm //@ compile-flags: -O -C panic=abort +//@ compile-flags: -Zmerge-functions=disabled //@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu +//@[x86_64] compile-flags: -Zmerge-functions=disabled //@[x86_64] needs-llvm-components: x86 //@[i686] compile-flags: --target i686-unknown-linux-gnu +//@[i686] compile-flags: -Zmerge-functions=disabled //@[i686] needs-llvm-components: x86 //@ compile-flags: -C llvm-args=--x86-asm-syntax=intel //@ compile-flags: -C target-feature=+avx512bw @@ -38,12 +41,6 @@ macro_rules! check { // -O and extern "C" guarantee that the selected register is always ax/xmm0 #[no_mangle] pub unsafe extern "C" fn $func() -> i32 { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " {0:", $modifier, "}, {0:", $modifier, "}"), out($reg) y); y diff --git a/tests/assembly/asm/x86-types.rs b/tests/assembly/asm/x86-types.rs index 8e229614420b6..e4a1e1583104f 100644 --- a/tests/assembly/asm/x86-types.rs +++ b/tests/assembly/asm/x86-types.rs @@ -1,8 +1,10 @@ //@ revisions: x86_64 i686 //@ assembly-output: emit-asm //@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu +//@[x86_64] compile-flags: -Zmerge-functions=disabled //@[x86_64] needs-llvm-components: x86 //@[i686] compile-flags: --target i686-unknown-linux-gnu +//@[i686] compile-flags: -Zmerge-functions=disabled //@[i686] needs-llvm-components: x86 //@ compile-flags: -C llvm-args=--x86-asm-syntax=intel //@ compile-flags: -C target-feature=+avx512bw @@ -283,12 +285,6 @@ macro_rules! check { ($func:ident $ty:ident $class:ident $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " {}, {}"), lateout($class) y, in($class) x); y @@ -300,12 +296,6 @@ macro_rules! check_reg { ($func:ident $ty:ident $reg:tt $mov:literal) => { #[no_mangle] pub unsafe fn $func(x: $ty) -> $ty { - // Hack to avoid function merging - extern "Rust" { - fn dont_merge(s: &str); - } - dont_merge(stringify!($func)); - let y; asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x); y