]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clang: work around asm output constraint problems
authorEric Dumazet <edumazet@google.com>
Fri, 19 Dec 2025 11:20:06 +0000 (11:20 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 20 Dec 2025 22:47:05 +0000 (14:47 -0800)
Work around clang problems with "=rm" asm constraint.

clang seems to always chose the memory output, while it is almost
always the worst choice.

Add ASM_OUTPUT_RM so that we can replace "=rm" constraint
where it matters for clang, while not penalizing gcc.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Suggested-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/compiler-clang.h
include/linux/compiler_types.h

index 107ce05bd16eb4a2ecb0f8cbf5c9efeab1845a1c..7edf1a07b53505cce6540d2871175abe7fb50d5d 100644 (file)
  */
 #define ASM_INPUT_G "ir"
 #define ASM_INPUT_RM "r"
+#define ASM_OUTPUT_RM "=r"
 
 /*
  * Declare compiler support for __typeof_unqual__() operator.
index 1280693766b9dd844ec7ca83053381799be12456..d3318a3c257775d4f44e8f2eb7911ac52eefecc5 100644 (file)
@@ -548,11 +548,12 @@ struct ftrace_likely_data {
 
 /*
  * Clang has trouble with constraints with multiple
- * alternative behaviors (mainly "g" and "rm").
+ * alternative behaviors ("g" , "rm" and "=rm").
  */
 #ifndef ASM_INPUT_G
   #define ASM_INPUT_G "g"
   #define ASM_INPUT_RM "rm"
+  #define ASM_OUTPUT_RM "=rm"
 #endif
 
 #ifdef CONFIG_CC_HAS_ASM_INLINE