[compiler-rt] [builtins][AArch32] Fix __gnu_* functions (PR #137638)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 30 09:15:52 PDT 2025


https://github.com/saturn691 updated https://github.com/llvm/llvm-project/pull/137638

>From feabb903c275f30f22184fbca639b4081a344d54 Mon Sep 17 00:00:00 2001
From: William Huynh <William.Huynh at arm.com>
Date: Mon, 28 Apr 2025 15:16:26 +0100
Subject: [PATCH 1/2] [builtins][AArch64] Fix __gnu_* functions

Move to a consistent calling convention for both Clang and GNU such
that they can be linked with each other.
---
 compiler-rt/lib/builtins/extendhfsf2.c | 4 ++--
 compiler-rt/lib/builtins/truncsfhf2.c  | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/lib/builtins/extendhfsf2.c b/compiler-rt/lib/builtins/extendhfsf2.c
index 0159ab09d3ebb..0dc8cf33cccb6 100644
--- a/compiler-rt/lib/builtins/extendhfsf2.c
+++ b/compiler-rt/lib/builtins/extendhfsf2.c
@@ -16,12 +16,12 @@ COMPILER_RT_ABI NOINLINE float __extendhfsf2(src_t a) {
   return __extendXfYf2__(a);
 }
 
-COMPILER_RT_ABI float __gnu_h2f_ieee(src_t a) { return __extendhfsf2(a); }
-
 #if defined(__ARM_EABI__)
 #if defined(COMPILER_RT_ARMHF_TARGET)
+AEABI_RTABI float __gnu_h2f_ieee(src_t a) { return __extendhfsf2(a); }
 AEABI_RTABI float __aeabi_h2f(src_t a) { return __extendhfsf2(a); }
 #else
+COMPILER_RT_ALIAS(__extendhfsf2, __gnu_h2f_ieee)
 COMPILER_RT_ALIAS(__extendhfsf2, __aeabi_h2f)
 #endif
 #endif
diff --git a/compiler-rt/lib/builtins/truncsfhf2.c b/compiler-rt/lib/builtins/truncsfhf2.c
index 379e7cb6f7845..310cacd93c558 100644
--- a/compiler-rt/lib/builtins/truncsfhf2.c
+++ b/compiler-rt/lib/builtins/truncsfhf2.c
@@ -16,12 +16,13 @@ COMPILER_RT_ABI NOINLINE dst_t __truncsfhf2(float a) {
   return __truncXfYf2__(a);
 }
 
-COMPILER_RT_ABI dst_t __gnu_f2h_ieee(float a) { return __truncsfhf2(a); }
 
 #if defined(__ARM_EABI__)
 #if defined(COMPILER_RT_ARMHF_TARGET)
+AEABI_RTABI dst_t __gnu_f2h_ieee(float a) { return __truncsfhf2(a); }
 AEABI_RTABI dst_t __aeabi_f2h(float a) { return __truncsfhf2(a); }
 #else
+COMPILER_RT_ALIAS(__truncsfhf2, __gnu_f2h_ieee)
 COMPILER_RT_ALIAS(__truncsfhf2, __aeabi_f2h)
 #endif
 #endif

>From 29b643124094dcd0c3bdbb10744d6b16e516179b Mon Sep 17 00:00:00 2001
From: William Huynh <William.Huynh at arm.com>
Date: Wed, 30 Apr 2025 17:15:39 +0100
Subject: [PATCH 2/2] fixup! [builtins][AArch64] Fix __gnu_* functions

---
 compiler-rt/lib/builtins/extendhfsf2.c | 1 +
 compiler-rt/lib/builtins/truncsfhf2.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/compiler-rt/lib/builtins/extendhfsf2.c b/compiler-rt/lib/builtins/extendhfsf2.c
index 0dc8cf33cccb6..22ce9150d6291 100644
--- a/compiler-rt/lib/builtins/extendhfsf2.c
+++ b/compiler-rt/lib/builtins/extendhfsf2.c
@@ -24,4 +24,5 @@ AEABI_RTABI float __aeabi_h2f(src_t a) { return __extendhfsf2(a); }
 COMPILER_RT_ALIAS(__extendhfsf2, __gnu_h2f_ieee)
 COMPILER_RT_ALIAS(__extendhfsf2, __aeabi_h2f)
 #endif
+COMPILER_RT_ABI float __gnu_h2f_ieee(src_t a) { return __extendhfsf2(a); }
 #endif
diff --git a/compiler-rt/lib/builtins/truncsfhf2.c b/compiler-rt/lib/builtins/truncsfhf2.c
index 310cacd93c558..e16dbeb3a1c4d 100644
--- a/compiler-rt/lib/builtins/truncsfhf2.c
+++ b/compiler-rt/lib/builtins/truncsfhf2.c
@@ -25,4 +25,5 @@ AEABI_RTABI dst_t __aeabi_f2h(float a) { return __truncsfhf2(a); }
 COMPILER_RT_ALIAS(__truncsfhf2, __gnu_f2h_ieee)
 COMPILER_RT_ALIAS(__truncsfhf2, __aeabi_f2h)
 #endif
+COMPILER_RT_ABI dst_t __gnu_f2h_ieee(float a) { return __truncsfhf2(a); }
 #endif



More information about the llvm-commits mailing list