From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11663 invoked by alias); 1 Jun 2014 22:58:27 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 11600 invoked by uid 48); 1 Jun 2014 22:58:22 -0000 From: "bernd.edlinger at hotmail dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/61190] [4.8/4.9/4.10 Regression] g++.old-deja/g++.mike/p4736b.C FAILs at -O2/-Os/-O3 Date: Sun, 01 Jun 2014 22:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 4.10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: bernd.edlinger at hotmail dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-06/txt/msg00023.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61190 --- Comment #2 from Bernd Edlinger --- Created attachment 32883 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32883&action=edit possible fix Well, the problem seems to be, that the thunk code is not emitted in the normal way using gimple code, but instead by the i386 back-end with a callback. This makes the thunk invisible to the ipa-pure-const pass, which assumes that all values just flow straight thu the thunk. See ipa-pure-const.c (analyze_function): if (fn->thunk.thunk_p || fn->alias) { /* Thunk gets propagated through, so nothing interesting happens. */ gcc_assert (ipa); return l; } But this is not true for a virtual base class: The thunk itself references the vtable, so if nothing else might need the vtable, the optimizer may remove the initalization of the vtable, which happened in this example. The most simple work around would be the attached patch, which simply falls back to emitting gimple code, if virtual base classes are used.