Re: [PATCH v3 03/11] riscv: Implement cmpxchg8/16() using Zabha

Alexandre Ghiti
2024-07-18T16:20:37Z

On Thu, Jul 18, 2024 at 6:06 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> On Thu, Jul 18, 2024 at 02:50:28PM GMT, Alexandre Ghiti wrote:
> ...
> > > > + \
> > > > + __asm__ __volatile__ ( \
> > > > + prepend \
> > > > + " amocas" cas_sfx " %0, %z2, %1\n" \
> > > > + append \
> > > > + : "+&r" (r), "+A" (*(p)) \
> > > > + : "rJ" (n) \
> > > > + : "memory"); \
> > > > + goto end; \
> > > > + } \
> > > > + \
> > > > +no_zabha_zacas:; \
> > > unnecessary ;
> >
> >
> > Actually it is, it fixes a warning encountered on llvm:
> > https://lore.kernel.org/linux-riscv/20240528193110.GA2196855@thelio-3990X/
>
> I'm not complaining about the 'end:' label. That one we need ';' because
> there's no following statement and labels must be followed by a statement.
> But no_zabha_zacas always has following statements.

My bad, that's another warning that is emitted by llvm and requires the ';':

../include/linux/atomic/atomic-arch-fallback.h:2026:9: warning: label
followed by a declaration is a C23 extension [-Wc23-extensions]
2026 | return raw_cmpxchg(&v->counter, old, new);
| ^
../include/linux/atomic/atomic-arch-fallback.h:55:21: note: expanded
from macro 'raw_cmpxchg'
55 | #define raw_cmpxchg arch_cmpxchg
| ^
../arch/riscv/include/asm/cmpxchg.h:310:2: note: expanded from macro
'arch_cmpxchg'
310 | _arch_cmpxchg((ptr), (o), (n), ".rl", ".aqrl",
\
| ^
../arch/riscv/include/asm/cmpxchg.h:269:3: note: expanded from macro
'_arch_cmpxchg'
269 | __arch_cmpxchg_masked(sc_sfx, ".b" cas_sfx,
\
| ^
../arch/riscv/include/asm/cmpxchg.h:178:2: note: expanded from macro
'__arch_cmpxchg_masked'
178 | u32 *__ptr32b = (u32 *)((ulong)(p) & ~0x3);
\
| ^

>
> Thanks,
> drew