panic in ivy_rng_store() when compiled with -O0
Dimitry Andric
dim at FreeBSD.org
Fri Oct 17 18:34:05 UTC 2014
On 17 Oct 2014, at 20:21, Xin Li <delphij at delphij.net> wrote:
> On 10/17/14 08:53, John Baldwin wrote:
>> On Friday, October 10, 2014 02:08:13 PM Navdeep Parhar wrote:
...
> movq %rdi,(%rdi) is obviously wrong (%rdi holds the result from
> rdrand), which I believed to be a compiler bug in register allocation.
>
> Navdeep have committed a change to mark 'tmp' input+output, which does
> fix the output but I'm not 100% sure if that's right, as 'tmp' is not
> considered an input of the inline assembler block, and this may break
> compile on other compilers, but for now it's better than previous
> situation.
>
> Speaking for the compiler issue, Dimitry have reported this upstream at:
>
> http://llvm.org/bugs/show_bug.cgi?id=21273
>
> There is a suggestion in the reply, that change 'tmp' to early clobber
> would workaround the issue, like:
>
> Index: ivy.c
> ===================================================================
> - --- ivy.c (revision 273195)
> +++ ivy.c (working copy)
> @@ -79,7 +79,7 @@
> "2:\n\t"
> "mov %2,%1\n\t" /* *buf = tmp */
> "3:"
> - - : "+q" (retry), "=m" (*buf), "+q" (tmp) : : "cc");
> + : "+q" (retry), "=m" (*buf), "=&q" (tmp) : : "cc");
Yes, this generates the correct code for all cases I tried, e.g. with
gcc 4.2 from base, gcc 4.7 through 5.0 from ports, clang 3.4, clang 3.5
and clang trunk, all at -O0 through -O3, and -Os.
So at the moment this fix is the best option, I think.
-Dimitry
More information about the freebsd-hackers
mailing list