From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 8 08:55:45 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 45FCA1065670; Thu, 8 Dec 2011 08:55:45 +0000 (UTC) (envelope-from raj@semihalf.com) Received: from smtp.semihalf.com (smtp.semihalf.com [213.17.239.109]) by mx1.freebsd.org (Postfix) with ESMTP id E6F508FC15; Thu, 8 Dec 2011 08:55:44 +0000 (UTC) Received: from localhost (unknown [213.17.239.109]) by smtp.semihalf.com (Postfix) with ESMTP id 7A8DFEBE32; Thu, 8 Dec 2011 09:37:02 +0100 (CET) X-Virus-Scanned: by amavisd-new at semihalf.com Received: from smtp.semihalf.com ([213.17.239.109]) by localhost (smtp.semihalf.com [213.17.239.109]) (amavisd-new, port 10024) with ESMTP id Z1Qh90lUHC2p; Thu, 8 Dec 2011 09:37:01 +0100 (CET) Received: from [10.0.0.79] (cardhu.semihalf.com [213.17.239.108]) by smtp.semihalf.com (Postfix) with ESMTPSA id 1DF74EBD4D; Thu, 8 Dec 2011 09:37:01 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Rafal Jaworowski In-Reply-To: Date: Thu, 8 Dec 2011 09:37:00 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20111119100150.GA1560@reks> To: Arnaud Lacombe X-Mailer: Apple Mail (2.1084) Cc: freebsd-hackers@freebsd.org, Gleb Kurtsou , Piotr Nowak , mdf@freebsd.org Subject: Re: gcc 4.2 miscompilation with -O2 -fno-omit-frame-pointer on amd64 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2011 08:55:45 -0000 On 2011-12-07, at 21:28, Arnaud Lacombe wrote: > Hi, >=20 > On Sat, Nov 19, 2011 at 5:01 AM, Gleb Kurtsou = wrote: >> Hi, >>=20 >> I was lucky to write a bit of code which gcc 4.2 fails to compile >> correctly with -O2. Too keep long story short the code fails for gcc >> from base system and last gcc 4.2 snapshot from ports. It works with = gcc >> 4.3, gcc 4.4 on FreeBSD and Linux. Clang from base is also good. -O = and >> -Os optimization levels are fine (I've tried with all -f* flags >> mentioned in documentation) >>=20 >> -O2 -fno-omit-frame-pointer combination is troublesome on amd64. I >> presume i386 should be fine. These options are also used for >> compilation of kernel (with debugging enabled) and modules. >>=20 >> I'm not able to share the code, but have a test case reproducing the >> bug. I've encountered the issue over a week ago and tried narrowing = it down >> to a simple test I could share but without much success. >>=20 >> The code itself is very common: initialize two structs on stack, call = a >> function with pointers to those stucts as arguments. A number of = inlined >> assertion functions. gcc fails to correctly optimize struct = assignments >> with -fno-omit-frame-pointer, I have a number of small structs = assigned, >> gcc decides not to use data coping but to assign fields directly. = I've >> tried disabling sra, tweaking sra parameters -- no luck in forcing it >> to copy data. Replacing one particular assignment with memcpy = produces >> correct code, but that's not a solution. >>=20 >> -O2 -fno-omit-frame-pointer -fno-inline is buggy >> -O2 -fno-omit-frame-pointer -frename-registers is buggy >>=20 >> I found similar issue with gcc 4.6, but I'm not able to reproduce it >> with gcc test case: >> https://bugzilla.redhat.com/show_bug.cgi?id=3D679924 >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D47893 >>=20 > this PR seems highly irrelevant, the cause has been identified to a > commit made in mid-2010, that's 3 years older than gcc in base. >=20 >> I'll be glad to help debugging it and will be hanging on #bsddev = during >> weekend as glk. >>=20 > at least, can you share the testcase and miscompilation details ? I believe we suffer from a very similar issue on PowerPC as well, we'll = provide detailed information shortly. Rafal