Skip to content

Commit 7453128

Browse files
committed
[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.
1 parent c8b14ba commit 7453128

12 files changed

+23
-126
lines changed

tests/assembly/asm/aarch64-modifiers.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ assembly-output: emit-asm
22
//@ compile-flags: -O -C panic=abort
33
//@ compile-flags: --target aarch64-unknown-linux-gnu
4+
//@ compile-flags: -Zmerge-functions=disabled
45
//@ needs-llvm-components: aarch64
56

67
#![feature(no_core, lang_items, rustc_attrs)]
@@ -29,12 +30,6 @@ macro_rules! check {
2930
// -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0
3031
#[no_mangle]
3132
pub unsafe extern "C" fn $func() -> i32 {
32-
// Hack to avoid function merging
33-
extern "Rust" {
34-
fn dont_merge(s: &str);
35-
}
36-
dont_merge(stringify!($func));
37-
3833
let y;
3934
asm!($code, out($reg) y);
4035
y

tests/assembly/asm/aarch64-types.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
//@ assembly-output: emit-asm
33
//@ [aarch64] compile-flags: --target aarch64-unknown-linux-gnu
44
//@ [aarch64] needs-llvm-components: aarch64
5+
//@ [aarch64] compile-flags: -Zmerge-functions=disabled
56
//@ [arm64ec] compile-flags: --target arm64ec-pc-windows-msvc
7+
//@ [arm64ec] compile-flags: -Zmerge-functions=disabled
68
//@ [arm64ec] needs-llvm-components: aarch64
79

810
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
@@ -113,12 +115,6 @@ macro_rules! check {
113115
($func:ident $ty:ident $class:ident $mov:literal $modifier:literal) => {
114116
#[no_mangle]
115117
pub unsafe fn $func(x: $ty) -> $ty {
116-
// Hack to avoid function merging
117-
extern "Rust" {
118-
fn dont_merge(s: &str);
119-
}
120-
dont_merge(stringify!($func));
121-
122118
let y;
123119
asm!(
124120
concat!($mov, " {:", $modifier, "}, {:", $modifier, "}"),
@@ -134,12 +130,6 @@ macro_rules! check_reg {
134130
($func:ident $ty:ident $reg:tt $mov:literal) => {
135131
#[no_mangle]
136132
pub unsafe fn $func(x: $ty) -> $ty {
137-
// Hack to avoid function merging
138-
extern "Rust" {
139-
fn dont_merge(s: &str);
140-
}
141-
dont_merge(stringify!($func));
142-
143133
let y;
144134
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
145135
y

tests/assembly/asm/arm-modifiers.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//@ compile-flags: -O -C panic=abort
33
//@ compile-flags: --target armv7-unknown-linux-gnueabihf
44
//@ compile-flags: -C target-feature=+neon
5+
//@ compile-flags: -Zmerge-functions=disabled
56
//@ needs-llvm-components: arm
67

78
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
@@ -40,12 +41,6 @@ macro_rules! check {
4041
// -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0
4142
#[no_mangle]
4243
pub unsafe extern "C" fn $func() -> $ty {
43-
// Hack to avoid function merging
44-
extern "Rust" {
45-
fn dont_merge(s: &str);
46-
}
47-
dont_merge(stringify!($func));
48-
4944
let y;
5045
asm!(concat!($mov, " {0:", $modifier, "}, {0:", $modifier, "}"), out($reg) y);
5146
y

tests/assembly/asm/arm-types.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//@ assembly-output: emit-asm
33
//@ compile-flags: --target armv7-unknown-linux-gnueabihf
44
//@ compile-flags: -C opt-level=0
5+
//@ compile-flags: -Zmerge-functions=disabled
56
//@[d32] compile-flags: -C target-feature=+d32
67
//@[neon] compile-flags: -C target-feature=+neon --cfg d32
78
//@[neon] filecheck-flags: --check-prefix d32
@@ -114,12 +115,6 @@ macro_rules! check {
114115
($func:ident $ty:ident $class:ident $mov:literal) => {
115116
#[no_mangle]
116117
pub unsafe fn $func(x: $ty) -> $ty {
117-
// Hack to avoid function merging
118-
extern "Rust" {
119-
fn dont_merge(s: &str);
120-
}
121-
dont_merge(stringify!($func));
122-
123118
let y;
124119
asm!(concat!($mov, " {}, {}"), out($class) y, in($class) x);
125120
y
@@ -131,12 +126,6 @@ macro_rules! check_reg {
131126
($func:ident $ty:ident $reg:tt $mov:literal) => {
132127
#[no_mangle]
133128
pub unsafe fn $func(x: $ty) -> $ty {
134-
// Hack to avoid function merging
135-
extern "Rust" {
136-
fn dont_merge(s: &str);
137-
}
138-
dont_merge(stringify!($func));
139-
140129
let y;
141130
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
142131
y

tests/assembly/asm/hexagon-types.rs

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ assembly-output: emit-asm
22
//@ compile-flags: --target hexagon-unknown-linux-musl
3+
//@ compile-flags: -Zmerge-functions=disabled
34
//@ needs-llvm-components: hexagon
45

56
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
@@ -41,12 +42,6 @@ macro_rules! check {
4142
($func:ident $ty:ident $class:ident) => {
4243
#[no_mangle]
4344
pub unsafe fn $func(x: $ty) -> $ty {
44-
// Hack to avoid function merging
45-
extern "Rust" {
46-
fn dont_merge(s: &str);
47-
}
48-
dont_merge(stringify!($func));
49-
5045
let y;
5146
asm!("{} = {}", out($class) y, in($class) x);
5247
y
@@ -58,12 +53,6 @@ macro_rules! check_reg {
5853
($func:ident $ty:ident $reg:tt) => {
5954
#[no_mangle]
6055
pub unsafe fn $func(x: $ty) -> $ty {
61-
// Hack to avoid function merging
62-
extern "Rust" {
63-
fn dont_merge(s: &str);
64-
}
65-
dont_merge(stringify!($func));
66-
6756
let y;
6857
asm!(concat!($reg, " = ", $reg), lateout($reg) y, in($reg) x);
6958
y
@@ -77,12 +66,6 @@ macro_rules! check_reg {
7766
// CHECK: InlineAsm End
7867
#[no_mangle]
7968
pub unsafe fn sym_static() {
80-
// Hack to avoid function merging
81-
extern "Rust" {
82-
fn dont_merge(s: &str);
83-
}
84-
dont_merge(stringify!($func));
85-
8669
asm!("r0 = #{}", sym extern_static);
8770
}
8871

@@ -92,12 +75,6 @@ pub unsafe fn sym_static() {
9275
// CHECK: InlineAsm End
9376
#[no_mangle]
9477
pub unsafe fn sym_fn() {
95-
// Hack to avoid function merging
96-
extern "Rust" {
97-
fn dont_merge(s: &str);
98-
}
99-
dont_merge(stringify!($func));
100-
10178
asm!("r0 = #{}", sym extern_func);
10279
}
10380

tests/assembly/asm/loongarch-type.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ assembly-output: emit-asm
22
//@ compile-flags: --target loongarch64-unknown-linux-gnu
3+
//@ compile-flags: -Zmerge-functions=disabled
34
//@ needs-llvm-components: loongarch
45

56
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
@@ -39,11 +40,6 @@ extern "C" {
3940
static extern_static: u8;
4041
}
4142

42-
// Hack to avoid function merging
43-
extern "Rust" {
44-
fn dont_merge(s: &str);
45-
}
46-
4743
// CHECK-LABEL: sym_fn:
4844
// CHECK: #APP
4945
// CHECK: pcalau12i $t0, %got_pc_hi20(extern_func)
@@ -67,8 +63,6 @@ pub unsafe fn sym_static() {
6763
macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
6864
#[no_mangle]
6965
pub unsafe fn $func(x: $ty) -> $ty {
70-
dont_merge(stringify!($func));
71-
7266
let y;
7367
asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
7468
y
@@ -78,8 +72,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
7872
macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
7973
#[no_mangle]
8074
pub unsafe fn $func(x: $ty) -> $ty {
81-
dont_merge(stringify!($func));
82-
8375
let y;
8476
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
8577
y

tests/assembly/asm/mips-types.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
//@ revisions: mips32 mips64
22
//@ assembly-output: emit-asm
33
//@[mips32] compile-flags: --target mips-unknown-linux-gnu
4+
//@[mips32] compile-flags: -Zmerge-functions=disabled
45
//@[mips32] needs-llvm-components: mips
56
//@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
7+
//@[mips64] compile-flags: -Zmerge-functions=disabled
68
//@[mips64] needs-llvm-components: mips
79

810
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
@@ -43,16 +45,9 @@ extern "C" {
4345
static extern_static: u8;
4446
}
4547

46-
// Hack to avoid function merging
47-
extern "Rust" {
48-
fn dont_merge(s: &str);
49-
}
50-
5148
macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
5249
#[no_mangle]
5350
pub unsafe fn $func(x: $ty) -> $ty {
54-
dont_merge(stringify!($func));
55-
5651
let y;
5752
asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
5853
y
@@ -62,8 +57,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
6257
macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
6358
#[no_mangle]
6459
pub unsafe fn $func(x: $ty) -> $ty {
65-
dont_merge(stringify!($func));
66-
6760
let y;
6861
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
6962
y

tests/assembly/asm/powerpc-types.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
//@ revisions: powerpc powerpc64
22
//@ assembly-output: emit-asm
33
//@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
4+
//@[powerpc] compile-flags: -Zmerge-functions=disabled
45
//@[powerpc] needs-llvm-components: powerpc
56
//@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
7+
//@[powerpc64] compile-flags: -Zmerge-functions=disabled
68
//@[powerpc64] needs-llvm-components: powerpc
79

810
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
@@ -43,16 +45,9 @@ extern "C" {
4345
static extern_static: u8;
4446
}
4547

46-
// Hack to avoid function merging
47-
extern "Rust" {
48-
fn dont_merge(s: &str);
49-
}
50-
5148
macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
5249
#[no_mangle]
5350
pub unsafe fn $func(x: $ty) -> $ty {
54-
dont_merge(stringify!($func));
55-
5651
let y;
5752
asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
5853
y
@@ -62,8 +57,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
6257
macro_rules! check_reg { ($func:ident, $ty:ty, $rego:tt, $regc:tt, $mov:literal) => {
6358
#[no_mangle]
6459
pub unsafe fn $func(x: $ty) -> $ty {
65-
dont_merge(stringify!($func));
66-
6760
let y;
6861
asm!(concat!($mov, " ", $rego, ", ", $rego), lateout($regc) y, in($regc) x);
6962
y

tests/assembly/asm/riscv-types.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,32 @@
22
//@ assembly-output: emit-asm
33

44
//@[riscv64] compile-flags: --target riscv64imac-unknown-none-elf
5+
//@[riscv64] compile-flags: -Zmerge-functions=disabled
56
//@[riscv64] needs-llvm-components: riscv
67

78
//@[riscv32] compile-flags: --target riscv32imac-unknown-none-elf
9+
//@[riscv32] compile-flags: -Zmerge-functions=disabled
810
//@[riscv32] needs-llvm-components: riscv
911

1012
//@[riscv64-zfhmin] compile-flags: --target riscv64imac-unknown-none-elf --cfg riscv64
13+
//@[riscv64-zfhmin] compile-flags: -Zmerge-functions=disabled
1114
//@[riscv64-zfhmin] needs-llvm-components: riscv
1215
//@[riscv64-zfhmin] compile-flags: -C target-feature=+zfhmin
1316
//@[riscv64-zfhmin] filecheck-flags: --check-prefix riscv64
1417

1518
//@[riscv32-zfhmin] compile-flags: --target riscv32imac-unknown-none-elf
19+
//@[riscv32-zfhmin] compile-flags: -Zmerge-functions=disabled
1620
//@[riscv32-zfhmin] needs-llvm-components: riscv
1721
//@[riscv32-zfhmin] compile-flags: -C target-feature=+zfhmin
1822

1923
//@[riscv64-zfh] compile-flags: --target riscv64imac-unknown-none-elf --cfg riscv64
24+
//@[riscv64-zfh] compile-flags: -Zmerge-functions=disabled
2025
//@[riscv64-zfh] needs-llvm-components: riscv
2126
//@[riscv64-zfh] compile-flags: -C target-feature=+zfh
2227
//@[riscv64-zfh] filecheck-flags: --check-prefix riscv64 --check-prefix zfhmin
2328

2429
//@[riscv32-zfh] compile-flags: --target riscv32imac-unknown-none-elf
30+
//@[riscv32-zfh] compile-flags: -Zmerge-functions=disabled
2531
//@[riscv32-zfh] needs-llvm-components: riscv
2632
//@[riscv32-zfh] compile-flags: -C target-feature=+zfh
2733
//@[riscv32-zfh] filecheck-flags: --check-prefix zfhmin
@@ -90,12 +96,6 @@ macro_rules! check {
9096
($func:ident $ty:ident $class:ident $mov:literal) => {
9197
#[no_mangle]
9298
pub unsafe fn $func(x: $ty) -> $ty {
93-
// Hack to avoid function merging
94-
extern "Rust" {
95-
fn dont_merge(s: &str);
96-
}
97-
dont_merge(stringify!($func));
98-
9999
let y;
100100
asm!(concat!($mov, " {}, {}"), out($class) y, in($class) x);
101101
y
@@ -107,12 +107,6 @@ macro_rules! check_reg {
107107
($func:ident $ty:ident $reg:tt $mov:literal) => {
108108
#[no_mangle]
109109
pub unsafe fn $func(x: $ty) -> $ty {
110-
// Hack to avoid function merging
111-
extern "Rust" {
112-
fn dont_merge(s: &str);
113-
}
114-
dont_merge(stringify!($func));
115-
116110
let y;
117111
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
118112
y

tests/assembly/asm/s390x-types.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ revisions: s390x
22
//@ assembly-output: emit-asm
33
//@[s390x] compile-flags: --target s390x-unknown-linux-gnu
4+
//@[s390x] compile-flags: -Zmerge-functions=disabled
45
//@[s390x] needs-llvm-components: systemz
56

67
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
@@ -42,16 +43,9 @@ extern "C" {
4243
static extern_static: u8;
4344
}
4445

45-
// Hack to avoid function merging
46-
extern "Rust" {
47-
fn dont_merge(s: &str);
48-
}
49-
5046
macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
5147
#[no_mangle]
5248
pub unsafe fn $func(x: $ty) -> $ty {
53-
dont_merge(stringify!($func));
54-
5549
let y;
5650
asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
5751
y
@@ -61,8 +55,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
6155
macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
6256
#[no_mangle]
6357
pub unsafe fn $func(x: $ty) -> $ty {
64-
dont_merge(stringify!($func));
65-
6658
let y;
6759
asm!(concat!($mov, " %", $reg, ", %", $reg), lateout($reg) y, in($reg) x);
6860
y

0 commit comments

Comments
 (0)