Messages in this thread | ![/](/images/icornerl.gif) | | From | Bill Wendling <> | Date | Wed, 10 Apr 2024 12:23:01 -0700 | Subject | Re: More annoying code generation by clang |
| |
On Tue, Apr 9, 2024 at 8:37 AM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Tue, Apr 9, 2024 at 3:45 AM Peter Zijlstra <peterz@infradead.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. > I plan on picking this up. Could you please create a WIP branch on GitHub with your current work?
-bw
> > > > > 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 >
| ![\](/images/icornerr.gif) |