Skip to content

Commit e18048a

Browse files
committed
Give the GNU and AEABI functions the right ABIs
A buildbot reported a failure in a hardfp build, related to ABI: the test was calling __mulsf3 and passing arguments in s0/s1, but the code inside __mulsf3 was reading them out of r0/r1. The ABI using GPRs is correct for __aeabi_fmul, but not for __mulsf3, which takes float arguments in accordance with whatever the normal ABI is. So in hardfp, the two functions behave differently. The obvious question is why anyone is linking this function in to a hardfp build in the first place - surely in a hardfp context clients would just use a vmul instruction instead of calling either of these entry points? But there seems to be no provision in builtins/CMakeLists.txt for leaving things out of hardfp builds. The generic __mulsf3.c is still included in a hardfp builtins library. So I've stuck with those basic premises, and just corrected my replacement functions to get the ABIs right.
1 parent 85e0ce8 commit e18048a

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

compiler-rt/lib/builtins/arm/divsf3.S

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@
1919
.text
2020
.p2align 2
2121

22-
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_fdiv, __divsf3)
23-
22+
#if __ARM_PCS_VFP
2423
DEFINE_COMPILERRT_FUNCTION(__divsf3)
24+
push {r4, lr}
25+
vmov r0, s0
26+
vmov r1, s1
27+
bl __aeabi_fdiv
28+
vmov s0, r0
29+
pop {r4, pc}
30+
#else
31+
DEFINE_COMPILERRT_FUNCTION_ALIAS(__divsf3, __aeabi_fdiv)
32+
#endif
33+
34+
DEFINE_COMPILERRT_FUNCTION(__aeabi_fdiv)
2535
// Extract the exponents of the inputs into r2 and r3, occupying bits 16-23
2636
// of each register so that there will be space lower down to store extra
2737
// data without exponent arithmetic carrying into it. In the process, check
@@ -603,6 +613,6 @@ LOCAL_LABEL(tab):
603613
.byte 0x82 // input [0xfc0000,0xfdffff], candidate outputs [0x82,0x82]
604614
.byte 0x81 // input [0xfe0000,0xffffff], candidate outputs [0x80,0x81]
605615

606-
END_COMPILERRT_FUNCTION(__divsf3)
616+
END_COMPILERRT_FUNCTION(__aeabi_fdiv)
607617

608618
NO_EXEC_STACK_DIRECTIVE

compiler-rt/lib/builtins/arm/mulsf3.S

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@
1919
.text
2020
.p2align 2
2121

22-
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_fmul, __mulsf3)
23-
22+
#if __ARM_PCS_VFP
2423
DEFINE_COMPILERRT_FUNCTION(__mulsf3)
24+
push {r4, lr}
25+
vmov r0, s0
26+
vmov r1, s1
27+
bl __aeabi_fmul
28+
vmov s0, r0
29+
pop {r4, pc}
30+
#else
31+
DEFINE_COMPILERRT_FUNCTION_ALIAS(__mulsf3, __aeabi_fmul)
32+
#endif
33+
34+
DEFINE_COMPILERRT_FUNCTION(__aeabi_fmul)
2535

2636
// Check if either input exponent is 00 or FF (i.e. not a normalized number),
2737
// and if so, branch out of line. If we don't branch out of line, then we've
@@ -304,6 +314,6 @@ LOCAL_LABEL(inf_NaN):
304314
orreq r0, r0, #0x400000 // otherwise, set the 'quiet NaN' bit
305315
bx lr // and return
306316

307-
END_COMPILERRT_FUNCTION(__mulsf3)
317+
END_COMPILERRT_FUNCTION(__aeabi_fmul)
308318

309319
NO_EXEC_STACK_DIRECTIVE

0 commit comments

Comments
 (0)