From 3bd6dd6a79706abe1bef1fd7d8bf3b04e530ef17 Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Wed, 6 Feb 2019 12:51:14 -0800 Subject: [PATCH] ANDROID: arm64: lse: fix LSE atomics with LTO LLVM's integrated assembler is always used for inline assembly with CONFIG_LTO_CLANG. Unlike gcc, LLVM considers each inline assembly block to be independent and therefore, any preambles that enable features must be included in each block. This change adds the necessary preamble to ARM64_LSE_ATOMIC_INSN to allow CONFIG_ARM64_LSE_ATOMICS to be enabled with LTO. Bug: 117299373 Bug: 133186739 Change-Id: Icc06361dc2a2dba0f5f967d7f540cac2753b3e9c Signed-off-by: Sami Tolvanen --- arch/arm64/include/asm/lse.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/lse.h b/arch/arm64/include/asm/lse.h index 8262325e2fc6..8be3b0f85182 100644 --- a/arch/arm64/include/asm/lse.h +++ b/arch/arm64/include/asm/lse.h @@ -20,7 +20,12 @@ #else /* __ASSEMBLER__ */ +#ifdef CONFIG_LTO_CLANG +#define __LSE_PREAMBLE ".arch armv8-a+lse\n" +#else __asm__(".arch_extension lse"); +#define __LSE_PREAMBLE +#endif /* Move the ll/sc atomics out-of-line */ #define __LL_SC_INLINE notrace @@ -33,7 +38,7 @@ __asm__(".arch_extension lse"); /* In-line patching at runtime */ #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \ - ALTERNATIVE(llsc, lse, ARM64_HAS_LSE_ATOMICS) + ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS) #endif /* __ASSEMBLER__ */ #else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */