[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <C0D6E68C-AA52-4097-A626-5B8FBC67D445@vmware.com>
Date: Thu, 5 Sep 2019 05:43:05 +0000
From: Nadav Amit <namit@...are.com>
To: Nick Desaulniers <ndesaulniers@...gle.com>
CC: Rasmus Villemoes <linux@...musvillemoes.dk>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Subject: Re: [PATCH v2 4/6] compiler-gcc.h: add asm_inline definition
> On Sep 4, 2019, at 5:18 PM, Nick Desaulniers <ndesaulniers@...gle.com> wrote:
>
> On Fri, Aug 30, 2019 at 4:15 PM Rasmus Villemoes
> <linux@...musvillemoes.dk> wrote:
>> This adds an asm_inline macro which expands to "asm inline" [1] when gcc
>> is new enough (>= 9.1), and just asm for older gccs and other
>> compilers.
>>
>> Using asm inline("foo") instead of asm("foo") overrules gcc's
>> heuristic estimate of the size of the code represented by the asm()
>> statement, and makes gcc use the minimum possible size instead. That
>> can in turn affect gcc's inlining decisions.
>>
>> I wasn't sure whether to make this a function-like macro or not - this
>> way, it can be combined with volatile as
>>
>> asm_inline volatile()
>>
>> but perhaps we'd prefer to spell that
>>
>> asm_inline_volatile()
>>
>> anyway.
>>
>> [1] Technically, asm __inline, since both inline and __inline__
>> are macros that attach various attributes, making gcc barf if one
>> literally does "asm inline()". However, the third spelling __inline is
>> available for referring to the bare keyword.
>>
>> Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
>> ---
>> include/linux/compiler-gcc.h | 4 ++++
>> include/linux/compiler_types.h | 4 ++++
>> 2 files changed, 8 insertions(+)
>>
>> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
>> index d7ee4c6bad48..544b87b41b58 100644
>> --- a/include/linux/compiler-gcc.h
>> +++ b/include/linux/compiler-gcc.h
>> @@ -172,3 +172,7 @@
>> #endif
>>
>> #define __no_fgcse __attribute__((optimize("-fno-gcse")))
>> +
>> +#if GCC_VERSION >= 90100
>
> Is it too late to ask for a feature test macro? Maybe one already
> exists? I was not able to find documentation or a bug on `asm
> inline`. I'm quite curious how you even found or heard of this
> feature. To the source we must go...
When I had some free time I wrote a detailed blog post about this issue:
https://nadav.amit.zone/linux/2018/10/10/newline.html
Which later Borislav took to gcc people:
https://lore.kernel.org/lkml/20181007091805.GA30687@zn.tnic/
Powered by blists - more mailing lists