Skip to content

Commit e0fb3ac

Browse files
[compiler-rt][AArch64] Allow platform-specific mangling of SME routines. (#119864)
Support platform-specific mangling to avoid the compiler emitting a call to a function that is mangled differently than the definition in the runtime library.
1 parent 92a4f4d commit e0fb3ac

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

compiler-rt/lib/builtins/aarch64/sme-abi.S

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ DEFINE_COMPILERRT_PRIVATE_FUNCTION(do_abort)
4040
.cfi_offset w30, -24
4141
.cfi_offset w29, -32
4242
.cfi_offset 46, -16
43-
bl __arm_sme_state
43+
bl SYMBOL_NAME(__arm_sme_state)
4444
tbz x0, #0, 2f
4545
1:
4646
smstop sm
@@ -54,7 +54,7 @@ END_COMPILERRT_FUNCTION(do_abort)
5454
// __arm_sme_state fills the result registers based on a local
5555
// that is set as part of the compiler-rt startup code.
5656
// __aarch64_has_sme_and_tpidr2_el0
57-
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sme_state)
57+
DEFINE_COMPILERRT_FUNCTION(__arm_sme_state)
5858
.variant_pcs __arm_sme_state
5959
BTI_C
6060
mov x0, xzr
@@ -70,9 +70,9 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sme_state)
7070
mrs x1, TPIDR2_EL0
7171
1:
7272
ret
73-
END_COMPILERRT_OUTLINE_FUNCTION(__arm_sme_state)
73+
END_COMPILERRT_FUNCTION(__arm_sme_state)
7474

75-
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_restore)
75+
DEFINE_COMPILERRT_FUNCTION(__arm_tpidr2_restore)
7676
.variant_pcs __arm_tpidr2_restore
7777
BTI_C
7878
// If TPIDR2_EL0 is nonnull, the subroutine aborts in some platform-specific
@@ -106,9 +106,9 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_restore)
106106
ret
107107
2:
108108
b SYMBOL_NAME(do_abort)
109-
END_COMPILERRT_OUTLINE_FUNCTION(__arm_tpidr2_restore)
109+
END_COMPILERRT_FUNCTION(__arm_tpidr2_restore)
110110

111-
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_save)
111+
DEFINE_COMPILERRT_FUNCTION(__arm_tpidr2_save)
112112
.variant_pcs __arm_tpidr2_save
113113
BTI_C
114114
// If the current thread does not have access to TPIDR2_EL0, the subroutine
@@ -147,9 +147,10 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_save)
147147
ret
148148
2:
149149
b SYMBOL_NAME(do_abort)
150-
END_COMPILERRT_OUTLINE_FUNCTION(__arm_tpidr2_save)
150+
END_COMPILERRT_FUNCTION(__arm_tpidr2_save)
151151

152-
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
152+
DEFINE_COMPILERRT_FUNCTION(__arm_za_disable)
153+
.cfi_startproc
153154
.variant_pcs __arm_za_disable
154155
BTI_C
155156
// If the current thread does not have access to SME, the subroutine does
@@ -166,7 +167,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
166167
.cfi_def_cfa w29, 16
167168
.cfi_offset w30, -8
168169
.cfi_offset w29, -16
169-
bl __arm_tpidr2_save
170+
bl SYMBOL_NAME(__arm_tpidr2_save)
170171

171172
// * Set TPIDR2_EL0 to null.
172173
msr TPIDR2_EL0, xzr
@@ -181,9 +182,10 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
181182
.cfi_restore w29
182183
0:
183184
ret
184-
END_COMPILERRT_OUTLINE_FUNCTION(__arm_za_disable)
185+
.cfi_endproc
186+
END_COMPILERRT_FUNCTION(__arm_za_disable)
185187

186-
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_get_current_vg)
188+
DEFINE_COMPILERRT_FUNCTION(__arm_get_current_vg)
187189
.variant_pcs __arm_get_current_vg
188190
BTI_C
189191

@@ -200,7 +202,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_get_current_vg)
200202
2:
201203
mov x0, xzr
202204
ret
203-
END_COMPILERRT_OUTLINE_FUNCTION(__arm_get_current_vg)
205+
END_COMPILERRT_FUNCTION(__arm_get_current_vg)
204206

205207
NO_EXEC_STACK_DIRECTIVE
206208

compiler-rt/lib/builtins/aarch64/sme-libc-mem-routines.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
The loop tail is handled by always copying 64 bytes from the end.
5353
*/
5454

55-
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sc_memcpy)
55+
DEFINE_COMPILERRT_FUNCTION(__arm_sc_memcpy)
5656
add srcend1, src, count
5757
add dstend1, dstin, count
5858
cmp count, 128
@@ -232,7 +232,7 @@ L(copy64_from_start):
232232
stp B_l, B_h, [dstin, 16]
233233
stp C_l, C_h, [dstin]
234234
ret
235-
END_COMPILERRT_OUTLINE_FUNCTION(__arm_sc_memcpy)
235+
END_COMPILERRT_FUNCTION(__arm_sc_memcpy)
236236

237237
DEFINE_COMPILERRT_FUNCTION_ALIAS(__arm_sc_memmove, __arm_sc_memcpy)
238238

@@ -250,7 +250,7 @@ DEFINE_COMPILERRT_FUNCTION_ALIAS(__arm_sc_memmove, __arm_sc_memcpy)
250250
#define dstend2 x4
251251
#define zva_val x5
252252

253-
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sc_memset)
253+
DEFINE_COMPILERRT_FUNCTION(__arm_sc_memset)
254254
#ifdef __ARM_FEATURE_SVE
255255
mov z0.b, valw
256256
#else
@@ -346,6 +346,6 @@ L(no_zva_loop):
346346
stp q0, q0, [dstend2, -64]
347347
stp q0, q0, [dstend2, -32]
348348
ret
349-
END_COMPILERRT_OUTLINE_FUNCTION(__arm_sc_memset)
349+
END_COMPILERRT_FUNCTION(__arm_sc_memset)
350350

351351
#endif // __aarch64__

0 commit comments

Comments
 (0)