From patchwork Mon Sep 20 18:05:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 65233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0CE37B70A6 for ; Tue, 21 Sep 2010 04:05:17 +1000 (EST) Received: (qmail 16814 invoked by alias); 20 Sep 2010 18:05:14 -0000 Received: (qmail 16804 invoked by uid 22791); 20 Sep 2010 18:05:13 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-pw0-f47.google.com (HELO mail-pw0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Sep 2010 18:05:07 +0000 Received: by pwj1 with SMTP id 1so1606186pwj.20 for ; Mon, 20 Sep 2010 11:05:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.126.2 with SMTP id y2mr7027822wfc.129.1285005905394; Mon, 20 Sep 2010 11:05:05 -0700 (PDT) Received: by 10.220.202.9 with HTTP; Mon, 20 Sep 2010 11:05:05 -0700 (PDT) In-Reply-To: <20100916234812.GE6006@kam.mff.cuni.cz> References: <20100916234812.GE6006@kam.mff.cuni.cz> Date: Mon, 20 Sep 2010 11:05:05 -0700 Message-ID: Subject: Re: PR tree-optimization/45605 From: "H.J. Lu" To: Jan Hubicka Cc: gcc-patches@gcc.gnu.org, mjambor@suse.cz, rguenther@suse.de X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Thu, Sep 16, 2010 at 4:48 PM, Jan Hubicka wrote: > Hi, > this patch fixes missed devirtualization seen in the attached testcase. > (shamelessly stolen from the testsuite). > > The problem is that we never actually try to fold the statement at gimple level > and thus we never try gimple_fold_obj_type_ref_known_binfo.  Adding it to > gimple_fold_obj_type_ref_known_binfo does not solve the problem since > gimple_fold_obj_type_ref_known_binfo.  returns NULL. > > This is because of code I added into it to prevent referring static function > from other ltrans units.  We call the function too early and cgraph is not built > yet and consequently it thinks function is not there. > > This patch adds static_object_in_other_unit_p that has fixed logic of detecting > this case and combine it with the other problem I encounter with my folding patch, > where we pick up values from external vtables that reffer to external static variables. > C++ represent these with EXTERN and STATIC flags together. > > The patch saves whopping 300 bytes on Mozilla binnary ;) > > Bootstrapped/regtested x86_64-linux, OK? > > > /* { dg-do compile } */ > /* { dg-options "-O1 -fdump-tree-ssa" } */ > > extern "C" { void abort(); } > > struct A > { >  int d; > >  A ()                     { d = 123; } >  A (const A & o)          { d = o.d;  } >  A (volatile const A & o) { d = o.d + 2; } > }; > > A bar() > { >  volatile A l; >  return l; > } > > main() > { >  A a = bar (); > >  if (a.d != 125) >    abort(); > >  return 0; > } > /* We should devirtualize call to D::Run */ > /* { dg-final { scan-tree-dump-times "D::Run (" 1 "ssa"} } */ > /* { dg-final { cleanup-tree-dump "ssa" } } */ > I got ERROR: g++.dg/tree-ssa/pr45605.C: error executing dg-final: couldn't compile regular expression pattern: parentheses () not balanced I checked in the enclosed patch. H.J. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6dac3e5..8316803 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-09-20 H.J. Lu + + * g++.dg/tree-ssa/pr45605.C: Add "\\". + 2010-09-20 Richard Guenther PR middle-end/45704 diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr45605.C b/gcc/testsuite/g++.dg/tree-ssa/pr45605.C index b47f91a..20c4ba8 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr45605.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr45605.C @@ -33,5 +33,5 @@ int main() { /* We should devirtualize call to D::Run */ -/* { dg-final { scan-tree-dump-times "D::Run (" 1 "ssa"} } */ +/* { dg-final { scan-tree-dump-times "D::Run \\(" 1 "ssa"} } */ /* { dg-final { cleanup-tree-dump "ssa" } } */