From owner-svn-src-head@FreeBSD.ORG Tue Oct 9 17:17:02 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1B0FF937; Tue, 9 Oct 2012 17:17:02 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) by mx1.freebsd.org (Postfix) with ESMTP id CB85A8FC0A; Tue, 9 Oct 2012 17:17:01 +0000 (UTC) Received: from [192.168.0.2] (cpc2-cmbg15-2-0-cust445.5-4.cable.virginmedia.com [86.26.13.190]) (authenticated bits=0) by theravensnest.org (8.14.5/8.14.5) with ESMTP id q99HGrDk003024 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Tue, 9 Oct 2012 17:16:59 GMT (envelope-from theraven@FreeBSD.org) Subject: Re: svn commit: r241373 - head/lib/libc/stdlib Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: David Chisnall In-Reply-To: <507451DE.9060909@freebsd.org> Date: Tue, 9 Oct 2012 18:16:48 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <977E1107-46D4-476F-A04D-AEFD87D1DE53@FreeBSD.org> References: <201210091425.q99EPFS6020787@svn.freebsd.org> <507451DE.9060909@freebsd.org> To: Andrey Chernov X-Mailer: Apple Mail (2.1278) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Eitan Adler X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Oct 2012 17:17:02 -0000 On 9 Oct 2012, at 17:33, Andrey Chernov wrote: > Do you check assembler output for _both_ cases? > In my testing clang and gcc xor's 'junk' properly in case it have > 'volatile' keyword (as in srandomdev()) and elide it without = 'volatile'. > IMHO this change should be backed out for srandomdev() and adding > 'volatile' for sranddev() instead. In it's original form, it is very dangerous - the whole expression = reduces to undefined and so the LLVM IR for the call is: call void @srand(i32 undef) The back end is then free to use any value for the call argument, = including any register value or 0. Since the value is passed in a = register, it will probably just use whatever the last value there is, = which may or may not be anything sensible. On MIPS, for example, this = is most likely to be &tv, and so is 100% deterministic. Adding the volatile means that we are doing an XOR with a value left on = the stack. If this is early on in the application, then it is most = likely to be 0. If it's later on, then there may be a value here, but = it's still not very likely to be something particularly unpredictable. =20= David=