[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdktV5vnKwET1PhM8x0urK+LUhAC=uc28RXHUsvq-7_vbA@mail.gmail.com>
Date: Tue, 9 Apr 2024 08:37:10 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>, Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, Peter Anvin <hpa@...or.com>,
"the arch/x86 maintainers" <x86@...nel.org>, Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
clang-built-linux <llvm@...ts.linux.dev>, Kees Cook <keescook@...omium.org>
Subject: Re: More annoying code generation by clang
On Tue, Apr 9, 2024 at 3:45 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Mon, Apr 08, 2024 at 12:42:31PM -0700, Linus Torvalds wrote:
>
> > Actually, one of the github issues pages has more of an explanation
> > (and yes, it's tied to impedance issues between the inline asm syntax
> > and how clang works):
> >
> > https://github.com/llvm/llvm-project/issues/20571#issuecomment-980933442
> >
>
> So that same issue seems to suggest Nick is actually working on this and
> got stuff merged. Nick, what is the status of your efforts and should we
> indeed do the below as Linus suggests or should he upgrade his compiler?
Sorry, I'm no longer working on the issue. I should mark that as such.
The feature got hung up on rewriting one of the register allocation
frameworks in llvm.
https://github.com/llvm/llvm-project/pull/74344
I have a new set of responsibilities at work so I probably wont be
working on that issue any time soon.
>
> > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> > index 49feac0162a5..0dee061fd7a6 100644
> > --- a/include/linux/compiler-clang.h
> > +++ b/include/linux/compiler-clang.h
> > @@ -118,3 +118,15 @@
> >
> > #define __diag_ignore_all(option, comment) \
> > __diag_clang(13, ignore, option)
> > +
> > +/*
> > + * clang has horrible behavior with "g" or "rm" constraints for asm
> > + * inputs, turning them into something worse than "m". Avoid using
> > + * constraints with multiple possible uses (but "ir" seems to be ok):
> > + *
> > + * https://github.com/llvm/llvm-project/issues/20571
> > + * https://github.com/llvm/llvm-project/issues/30873
> > + * https://github.com/llvm/llvm-project/issues/34837
20571 is the cannonical bug for this.
> > + */
> > +#define ASM_INPUT_G "ir"
> > +#define ASM_INPUT_RM "r"
> > diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> > index 2abaa3a825a9..e53acd310545 100644
> > --- a/include/linux/compiler_types.h
> > +++ b/include/linux/compiler_types.h
> > @@ -380,6 +380,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
> > --
> > 2.44.0.330.g4d18c88175
> >
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists