[PATCH] gcc4: Add 'asm goto' miscompilation quirk
From: Ingo Molnar
Date: Thu Oct 10 2013 - 04:24:49 EST
* Jakub Jelinek <jakub@xxxxxxxxxx> wrote:
> On Thu, Oct 10, 2013 at 08:51:04AM +0200, Jakub Jelinek wrote:
> > @@ -8,6 +8,7 @@ foo (int a, int b)
> > asm volatile goto ("bts $1, %0; jc %l[lab]" : : "m" (b) : "memory" : lab);
> > return 0;
> > lab:
> > + asm ("");
> > return 0;
> > }
>
> Or alternatively put the asm (""); right after asm goto,
> asm volatile goto ("bts $1, %0; jc %l[lab]" : : "m" (b) : "memory" : lab);
> asm ("");
> return ...;
> lab;
> return ...;
> What generates better code remains to be tested. In any case, please
> conditionalize the hacks on non-fixed compilers once the fix is released.
Something like the patch below? (Totally untested and all that.)
Notes:
- If the bug is fixed in 4.8.3 then the version check can be sharpened
from 99999 to 40803.
- I'd really prefer this quirk versus having to add the extra barrier to
the label, as it makes the actual usage sites a lot less painful.
Thanks,
Ingo
=======================>