summaryrefslogtreecommitdiffstats
path: root/include/linux/compiler_types.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2024-04-08 11:38:30 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2024-05-22 14:12:11 -0700
commitdbaaabd60e1662d2659eaeab0a4fc521667737ed (patch)
treefe79efbe1efa9c9bb88b96a7735b49664b82d99a /include/linux/compiler_types.h
parenta38297e3fb012ddfa7ce0321a7e5a8daeb1872b6 (diff)
downloadlinux-dbaaabd60e1662d2659eaeab0a4fc521667737ed.tar.gz
linux-dbaaabd60e1662d2659eaeab0a4fc521667737ed.tar.bz2
linux-dbaaabd60e1662d2659eaeab0a4fc521667737ed.zip
clang: work around asm input constraint problems
Work around clang problems with asm constraints that have multiple possibilities, particularly "g" and "rm". Clang seems to turn inputs like that into the most generic form, which is the memory input - but to make matters worse, clang won't even use a possible original memory location, but will spill the value to stack, and use the stack for the asm input. See https://github.com/llvm/llvm-project/issues/20571#issuecomment-980933442 for some explanation of why clang has this strange behavior, but the end result is that "g" and "rm" really end up generating horrid code. Link: https://github.com/llvm/llvm-project/issues/20571 Cc: Peter Zijlstra <peterz@infradead.org> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/compiler_types.h')
-rw-r--r--include/linux/compiler_types.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 8f8236317d5b..f82bdac63961 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -391,6 +391,15 @@ struct ftrace_likely_data {
#define asm_goto_output(x...) asm volatile goto(x)
#endif
+/*
+ * Clang has trouble with constraints with multiple
+ * alternative behaviors (mainly "g" and "rm").
+ */
+#ifndef ASM_INPUT_G
+ #define ASM_INPUT_G "g"
+ #define ASM_INPUT_RM "rm"
+#endif
+
#ifdef CONFIG_CC_HAS_ASM_INLINE
#define asm_inline asm __inline
#else