Skip to content

Commit adcee23

Browse files
Rollup merge of rust-lang#129468 - Rajveer100:hack-to-avoid-function-merging, r=Mark-Simulacrum
[testsuite][cleanup] Remove all usages of `dont_merge` hack to avoid function merging Resolves rust-lang#129438 The `-Zmerge-functions=disabled` compile flag exists for this purpose.
2 parents 5a2ebb5 + b324fcb commit adcee23

12 files changed

+12
-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

+1-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//@ [aarch64] needs-llvm-components: aarch64
55
//@ [arm64ec] compile-flags: --target arm64ec-pc-windows-msvc
66
//@ [arm64ec] needs-llvm-components: aarch64
7+
//@ compile-flags: -Zmerge-functions=disabled
78

89
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch, f16, f128)]
910
#![crate_type = "rlib"]
@@ -132,12 +133,6 @@ macro_rules! check {
132133
// LLVM issue: <https://github.com/llvm/llvm-project/issues/94434>
133134
#[no_mangle]
134135
pub unsafe fn $func(inp: &$ty, out: &mut $ty) {
135-
// Hack to avoid function merging
136-
extern "Rust" {
137-
fn dont_merge(s: &str);
138-
}
139-
dont_merge(stringify!($func));
140-
141136
let x = *inp;
142137
let y;
143138
asm!(
@@ -155,12 +150,6 @@ macro_rules! check_reg {
155150
// FIXME(f16_f128): See FIXME in `check!`
156151
#[no_mangle]
157152
pub unsafe fn $func(inp: &$ty, out: &mut $ty) {
158-
// Hack to avoid function merging
159-
extern "Rust" {
160-
fn dont_merge(s: &str);
161-
}
162-
dont_merge(stringify!($func));
163-
164153
let x = *inp;
165154
let y;
166155
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//@[mips32] needs-llvm-components: mips
55
//@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
66
//@[mips64] needs-llvm-components: mips
7+
//@ compile-flags: -Zmerge-functions=disabled
78

89
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
910
#![crate_type = "rlib"]
@@ -43,16 +44,9 @@ extern "C" {
4344
static extern_static: u8;
4445
}
4546

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

tests/assembly/asm/powerpc-types.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//@[powerpc] needs-llvm-components: powerpc
55
//@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
66
//@[powerpc64] needs-llvm-components: powerpc
7+
//@ compile-flags: -Zmerge-functions=disabled
78

89
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
910
#![crate_type = "rlib"]
@@ -43,16 +44,9 @@ extern "C" {
4344
static extern_static: u8;
4445
}
4546

46-
// Hack to avoid function merging
47-
extern "Rust" {
48-
fn dont_merge(s: &str);
49-
}
50-
5147
macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
5248
#[no_mangle]
5349
pub unsafe fn $func(x: $ty) -> $ty {
54-
dont_merge(stringify!($func));
55-
5650
let y;
5751
asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
5852
y
@@ -62,8 +56,6 @@ macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
6256
macro_rules! check_reg { ($func:ident, $ty:ty, $rego:tt, $regc:tt, $mov:literal) => {
6357
#[no_mangle]
6458
pub unsafe fn $func(x: $ty) -> $ty {
65-
dont_merge(stringify!($func));
66-
6759
let y;
6860
asm!(concat!($mov, " ", $rego, ", ", $rego), lateout($regc) y, in($regc) x);
6961
y

tests/assembly/asm/riscv-types.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
//@[riscv32-zfh] filecheck-flags: --check-prefix zfhmin
2828

2929
//@ compile-flags: -C target-feature=+d
30+
//@ compile-flags: -Zmerge-functions=disabled
3031

3132
#![feature(no_core, lang_items, rustc_attrs, f16)]
3233
#![crate_type = "rlib"]
@@ -90,12 +91,6 @@ macro_rules! check {
9091
($func:ident $ty:ident $class:ident $mov:literal) => {
9192
#[no_mangle]
9293
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-
9994
let y;
10095
asm!(concat!($mov, " {}, {}"), out($class) y, in($class) x);
10196
y
@@ -107,12 +102,6 @@ macro_rules! check_reg {
107102
($func:ident $ty:ident $reg:tt $mov:literal) => {
108103
#[no_mangle]
109104
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-
116105
let y;
117106
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
118107
y

tests/assembly/asm/s390x-types.rs

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

67
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
78
#![crate_type = "rlib"]
@@ -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

tests/assembly/asm/x86-modifiers.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//@[i686] needs-llvm-components: x86
88
//@ compile-flags: -C llvm-args=--x86-asm-syntax=intel
99
//@ compile-flags: -C target-feature=+avx512bw
10+
//@ compile-flags: -Zmerge-functions=disabled
1011

1112
#![feature(no_core, lang_items, rustc_attrs)]
1213
#![crate_type = "rlib"]
@@ -38,12 +39,6 @@ macro_rules! check {
3839
// -O and extern "C" guarantee that the selected register is always ax/xmm0
3940
#[no_mangle]
4041
pub unsafe extern "C" fn $func() -> i32 {
41-
// Hack to avoid function merging
42-
extern "Rust" {
43-
fn dont_merge(s: &str);
44-
}
45-
dont_merge(stringify!($func));
46-
4742
let y;
4843
asm!(concat!($mov, " {0:", $modifier, "}, {0:", $modifier, "}"), out($reg) y);
4944
y

tests/assembly/asm/x86-types.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//@[i686] needs-llvm-components: x86
77
//@ compile-flags: -C llvm-args=--x86-asm-syntax=intel
88
//@ compile-flags: -C target-feature=+avx512bw
9+
//@ compile-flags: -Zmerge-functions=disabled
910

1011
#![feature(no_core, lang_items, rustc_attrs, repr_simd, f16, f128)]
1112
#![crate_type = "rlib"]
@@ -283,12 +284,6 @@ macro_rules! check {
283284
($func:ident $ty:ident $class:ident $mov:literal) => {
284285
#[no_mangle]
285286
pub unsafe fn $func(x: $ty) -> $ty {
286-
// Hack to avoid function merging
287-
extern "Rust" {
288-
fn dont_merge(s: &str);
289-
}
290-
dont_merge(stringify!($func));
291-
292287
let y;
293288
asm!(concat!($mov, " {}, {}"), lateout($class) y, in($class) x);
294289
y
@@ -300,12 +295,6 @@ macro_rules! check_reg {
300295
($func:ident $ty:ident $reg:tt $mov:literal) => {
301296
#[no_mangle]
302297
pub unsafe fn $func(x: $ty) -> $ty {
303-
// Hack to avoid function merging
304-
extern "Rust" {
305-
fn dont_merge(s: &str);
306-
}
307-
dont_merge(stringify!($func));
308-
309298
let y;
310299
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
311300
y

0 commit comments

Comments
 (0)