From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 17 18:34:05 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 26342FC6; Fri, 17 Oct 2014 18:34:05 +0000 (UTC) Received: from tensor.andric.com (unknown [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DB214C92; Fri, 17 Oct 2014 18:34:04 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::74:4835:c62e:9c49] (unknown [IPv6:2001:7b8:3a7:0:74:4835:c62e:9c49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 60284B80A; Fri, 17 Oct 2014 20:34:00 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) Subject: Re: panic in ivy_rng_store() when compiled with -O0 From: Dimitry Andric In-Reply-To: <54415E13.4000203@delphij.net> Date: Fri, 17 Oct 2014 20:33:57 +0200 Content-Transfer-Encoding: 7bit Message-Id: <7A5C3D84-1B1F-4BA3-818D-37231BF424FE@FreeBSD.org> References: <54384ABD.5080806@FreeBSD.org> <2533199.DHZybpy49d@ralph.baldwin.cx> <54415E13.4000203@delphij.net> To: d@delphij.net X-Mailer: Apple Mail (2.1990.1) Cc: freebsd-hackers@freebsd.org, Navdeep Parhar X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2014 18:34:05 -0000 On 17 Oct 2014, at 20:21, Xin Li 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