Re: More annoying code generation by clang
From: Linus Torvalds
Date: Mon Apr 08 2024 - 14:32:46 EST
On Mon, 8 Apr 2024 at 01:49, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> Should this not carry a comment about the "ir" constraint wanting to be
> "g" except for clang being daft?
Yeah. Except I think I'll do something like
/* Clang messes up "g" as an asm source */
#define ASM_SOURCE_G "ir"
in <linux/compiler-clang.h>, and
#ifndef ASM_SOURCE_G
#define ASM_SOURCE_G "g"
#endif
in linux/compiler.h.
> (I really wish clang would go fix this, it keeps coming up time and
> again).
It's been reported long ago, it seems to be hard to fix.
I suspect the issue is that the inline asm format is fairly closely
related to the gcc machine descriptions (look at the machine
descriptor files in gcc, and if you can ignore the horrid LISP-style
syntax you see how close they are).
And clang has a different model and needs to "translate" things, and
that one doesn't translate.
It's not like we don't have workarounds for gcc bugs in this area too
(eg "asm_goto_output()", née "asm_volatile_goto()").
There was another bug in my patch, though: the output mask should
always be "unsigned long", not tied to the input type.
Linus