Re: [PATCH] riscv/atomic: Do proper sign extension also for unsigned in arch_cmpxchg
From: Maciej W. Rozycki
Date: Mon Feb 03 2025 - 08:58:10 EST
On Thu, 30 Jan 2025, Jessica Clarke wrote:
> >> a2 is used as it is passed by the calling function, so we can't be sure a2
> >> is sign extended to me, what am I missing?
> >
> > 32-bit scalar arguments are guaranteed to be sign extended on entry.
>
> Firstly, the calling convention is irrelevant if the function is
> inlined, which this almost always will be.
Umm, that would be a compiler bug then, as inlining is supposed not to
change language semantics. IOW the compiler is expected to explicitly
sign-extend the arguments of an inlined function at their evaluation point
just as it would at an actual function call unless the compiler is able to
prove they have come out sign-extended already from previous operations.
Maciej