Re: [PATCH RFC v2 02/25] stackdepot: prevent Clang from optimizing away stackdepot_memcmp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 1, 2019 at 6:50 AM Sergey Senozhatsky
<sergey.senozhatsky.work@xxxxxxxxx> wrote:
>
> On (19/10/30 15:22), glider@xxxxxxxxxx wrote:
> > Clang may replace stackdepot_memcmp() with a call to instrumented bcmp(),
> > which is exactly what we wanted to avoid creating stackdepot_memcmp().
> > Add a compiler barrier() to prevent optimizations.
>
> [..]
>
> > @@ -163,6 +163,11 @@ int stackdepot_memcmp(const unsigned long *u1, const unsigned long *u2,
> >                       unsigned int n)
> >  {
> >       for ( ; n-- ; u1++, u2++) {
> > +             /*
> > +              * Prevent Clang from replacing this function with a bcmp()
> > +              * call.
> > +              */
> > +             barrier();
> >               if (*u1 != *u2)
> >                       return 1;
> >       }
>
> Would 'volatile' do the trick?
It does. I can replace the barrier with a volatile if you think that's better.
However this'll add a checkpatch warning, as volatiles are discouraged
for synchronization (although in this case there's no synchronization)
>
>         -ss



-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux