From: Ian Rogers Date: Sat, 30 May 2020 08:20:13 +0000 (-0700) Subject: tools compiler.h: Add attribute to disable tail calls X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=21f2b7c13335eeec498569927d87c7381c3b54fa;p=linux.git tools compiler.h: Add attribute to disable tail calls Tail call optimizations can remove stack frames that are used in unwinding tests. Add an attribute that can be used to disable the tail call optimization. Tested on clang and GCC. Committer notes: Old versions of clang don't like that __attribute__((optimize)), so add an ifdef to make it go away. Signed-off-by: Ian Rogers Cc: Alexander Shishkin Cc: Alexei Starovoitov Cc: clang-built-linux@googlegroups.com Cc: Jakub Kicinski Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Quentin Monnet Cc: Stephane Eranian Link: http://lore.kernel.org/lkml/20200530082015.39162-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/include/linux/compiler-gcc.h b/tools/include/linux/compiler-gcc.h index 95c072b70d0e8..b9d4322e1e655 100644 --- a/tools/include/linux/compiler-gcc.h +++ b/tools/include/linux/compiler-gcc.h @@ -27,6 +27,18 @@ #define __pure __attribute__((pure)) #endif #define noinline __attribute__((noinline)) +#ifdef __has_attribute +#if __has_attribute(disable_tail_calls) +#define __no_tail_call __attribute__((disable_tail_calls)) +#endif +#endif +#ifndef __no_tail_call +#if GCC_VERSION > 40201 +#define __no_tail_call __attribute__((optimize("no-optimize-sibling-calls"))) +#else +#define __no_tail_call +#endif +#endif #ifndef __packed #define __packed __attribute__((packed)) #endif diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h index 180f7714a5f10..9f9002734e192 100644 --- a/tools/include/linux/compiler.h +++ b/tools/include/linux/compiler.h @@ -47,6 +47,9 @@ #ifndef noinline #define noinline #endif +#ifndef __no_tail_call +#define __no_tail_call +#endif /* Are two types/vars the same type (ignoring qualifiers)? */ #ifndef __same_type