Re: [PATCH, -v2] compiler/gcc4: Add quirk for 'asm goto'miscompilation bug

From: Peter Zijlstra
Date: Thu Oct 10 2013 - 07:56:45 EST


On Thu, Oct 10, 2013 at 10:55:06AM +0200, Ingo Molnar wrote:
> +/*
> + * GCC 'asm goto' miscompiles certain code sequences:
> + *
> + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
> + *
> + * Work it around via quirk suggested by Jakub Jelinek.
> + * Fixed in GCC 4.8.2 and later versions.
> + */
> +#if GCC_VERSION <= 40801

We didn't do version checks for CC_HAVE_ASM_GOTO because of vendor
backports; can't we detect this in the same way?

> +# define __asm_goto(vol, x...) do { asm vol goto(x); asm (""); } while (0)
> +#else
> +# define __asm_goto(vol, x...) do { asm vol goto(x); } while (0)
> +#endif

This places the asm("") in the fallthrough case; but Jakub 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;
> }

Which places the asm ("") after the label, these two are not the same.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/