From 8ed31fc5c8722d5f94a90e28cdc8d99fd66f943e Mon Sep 17 00:00:00 2001 From: eshiner Date: Tue, 23 Sep 2025 17:27:15 +0800 Subject: [PATCH] [compiler-rt] Support HARDCODE_NO_LSE to disable lse atomic Currently in compiler-rt, using dynamic detect for LSE support. But for some soc/ship, there was something wrong with LSE atomic instructions, so we need DISBALE it by HARDCODE. Signed-off-by: eshiner --- .../compiler-rt/lib/builtins/aarch64/lse.S | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S b/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S index 1fe18f4..31577a4 100644 --- a/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S +++ b/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S @@ -129,6 +129,7 @@ HIDDEN(___aarch64_have_lse_atomics) #define tmp1 17 #define tmp2 15 +#ifndef HARDCODED_NO_LSE // Macro for branch to label if no LSE available .macro JUMP_IF_NOT_LSE label #if !defined(__APPLE__) @@ -140,11 +141,15 @@ HIDDEN(___aarch64_have_lse_atomics) #endif cbz w(tmp0), \label .endm +#endif // HARDCODED_NO_LSE #ifdef L_cas DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) +#ifndef HARDCODED_NO_LSE JUMP_IF_NOT_LSE 8f +#endif // HARDCODED_NO_LSE #if SIZE < 16 +#ifndef HARDCODED_NO_LSE #ifdef HAS_ASM_LSE #define CAS GLUE4(cas, A, L, S) s(0), s(1), [x2] #else @@ -153,6 +158,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) CAS // s(0), s(1), [x2] ret 8: +#endif // HARDCODED_NO_LSE + mov s(tmp0), s(0) UXT s(tmp0), s(0) 0: LDXR s(0), [x2] @@ -171,6 +178,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) #define LDXP GLUE3(ld, A, xp) #endif #define STXP GLUE3(st, L, xp) +#ifndef HARDCODED_NO_LSE #ifdef HAS_ASM_LSE #define CASP GLUE3(casp, A, L) x0, x1, x2, x3, [x4] #else @@ -180,6 +188,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) CASP // x0, x1, x2, x3, [x4] ret 8: +#endif // HARDCODED_NO_LSE mov x(tmp0), x0 mov x(tmp1), x1 0: @@ -197,16 +206,20 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(cas)) #endif // L_cas #ifdef L_swp +#ifndef HARDCODED_NO_LSE #ifdef HAS_ASM_LSE #define SWP GLUE4(swp, A, L, S) s(0), s(0), [x1] #else #define SWP .inst 0x38208020 + B + N #endif +#endif // HARDCODED_NO_LSE DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(swp)) +#ifndef HARDCODED_NO_LSE JUMP_IF_NOT_LSE 8f SWP // s(0), s(0), [x1] ret 8: +#endif // HARDCODED_NO_LSE mov s(tmp0), s(0) 0: LDXR s(0), [x1] @@ -240,17 +253,21 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(swp)) #error #endif +#ifndef HARDCODED_NO_LSE #ifdef HAS_ASM_LSE #define LDOP GLUE4(LDNM, A, L, S) s(0), s(0), [x1] #else #define LDOP .inst 0x38200020 + OPN + B + N #endif +#endif // HARDCODED_NO_LSE DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(LDNM)) +#ifndef HARDCODED_NO_LSE JUMP_IF_NOT_LSE 8f LDOP // s(0), s(0), [x1] ret 8: +#endif // HARDCODED_NO_LSE mov s(tmp0), s(0) 0: LDXR s(0), [x1] -- 2.51.0.windows.1