[glibc/azanella/clang] stdlib: longlong.h: Do no use asm input cast for clang
Andrew Pinski
pinskia@gmail.com
Tue Apr 15 15:53:25 GMT 2025
On Tue, Apr 15, 2025 at 6:43 AM Maciej W. Rozycki <macro@orcam.me.uk> wrote:
>
> On Thu, 10 Apr 2025, Adhemerval Zanella via Glibc-cvs wrote:
>
> > diff --git a/stdlib/longlong.h b/stdlib/longlong.h
> > index 4549f0a55f..2ec82d0315 100644
> > --- a/stdlib/longlong.h
> > +++ b/stdlib/longlong.h
> > @@ -57,6 +57,14 @@
> > #define attribute_hidden
> > #endif
> >
> > +/* clang does not support output constraint as lvalue, while gcc uses it as a
> > + simple type check. */
> > +#ifdef __clang__
> > +# define __asm_output_check_type(__type, __arg) (__arg)
> > +#else
> > +# define __asm_output_check_type(__type, __arg) ((__type)(__arg))
> ^
> Missing space here.
>
> NB LLVM has at least one GNU inline asm handling bug that necessarily
> pessimises code produced by GCC if worked around for LLVM acceptance.
> The case I know of is the requirement for an output to be of the same data
> type as an input where both are assigned via constraints to the same
> register.
>
> It is entirely unfounded, because in many cases processor registers can
> carry data of several types and code within inline asm may well produce
> data of a different type from one it has received in said register, e.g.
> input can be `long' and output can be `int', and the constraints of either
> hardware or the algorithm may require both to stay in the same register,
> but LLVM rejects such code. It has hit us in the Linux kernel already.
>
> Therefore please let's make sure we do not regress GNU software while
> adding support for a non-GNU compiler. E.g. for the case above we'd
> probably want two entirely separate inline asm pieces for each of the
> compilers.
Note in this case is a bit odd since this extension is only GNU C (GNU
C++ rejects it), and has been known not to be documented since 2001
(https://gcc.gnu.org/PR2803). I was thinking about removing the
(undocumented) extension for GCC 16 but maybe it is better to document
it and move on.
Thanks,
Andrew Pinski
>
> Maciej
More information about the Libc-alpha
mailing list