linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Compiler attributes: Introduce the __preserve_most function attribute
@ 2023-08-02 15:06 Marco Elver
  2023-08-02 15:06 ` [PATCH 2/3] list_debug: Introduce inline wrappers for debug checks Marco Elver
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Marco Elver @ 2023-08-02 15:06 UTC (permalink / raw)
  To: elver, Andrew Morton, Kees Cook
  Cc: Guenter Roeck, Marc Zyngier, Oliver Upton, James Morse,
	Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon,
	Miguel Ojeda, Nick Desaulniers, Nathan Chancellor, Tom Rix,
	linux-arm-kernel, kvmarm, linux-kernel, llvm, Dmitry Vyukov,
	Alexander Potapenko, kasan-dev, linux-toolchains

[1]: "On X86-64 and AArch64 targets, this attribute changes the calling
convention of a function. The preserve_most calling convention attempts
to make the code in the caller as unintrusive as possible. This
convention behaves identically to the C calling convention on how
arguments and return values are passed, but it uses a different set of
caller/callee-saved registers. This alleviates the burden of saving and
recovering a large register set before and after the call in the
caller."

[1] https://clang.llvm.org/docs/AttributeReference.html#preserve-most

Use of this attribute results in better code generation for calls to
very rarely called functions, such as error-reporting functions, or
rarely executed slow paths.

Introduce the attribute to compiler_attributes.h.

Signed-off-by: Marco Elver <elver@google.com>
---
 include/linux/compiler_attributes.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
index 00efa35c350f..615a63ecfcf6 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -321,6 +321,17 @@
 # define __pass_object_size(type)
 #endif
 
+/*
+ * Optional: not supported by gcc.
+ *
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#preserve-most
+ */
+#if __has_attribute(__preserve_most__)
+# define __preserve_most __attribute__((__preserve_most__))
+#else
+# define __preserve_most
+#endif
+
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
  */
-- 
2.41.0.585.gd2178a4bd4-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-02 18:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02 15:06 [PATCH 1/3] Compiler attributes: Introduce the __preserve_most function attribute Marco Elver
2023-08-02 15:06 ` [PATCH 2/3] list_debug: Introduce inline wrappers for debug checks Marco Elver
2023-08-02 15:06 ` [PATCH 3/3] list_debug: Introduce CONFIG_DEBUG_LIST_MINIMAL Marco Elver
2023-08-02 16:50 ` [PATCH 1/3] Compiler attributes: Introduce the __preserve_most function attribute Marco Elver
2023-08-02 17:08   ` Miguel Ojeda
2023-08-02 18:03 ` Andrew Morton
2023-08-02 18:51   ` Marco Elver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).