From patchwork Wed Feb 20 15:01:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 222096 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 18F182C0077 for ; Thu, 21 Feb 2013 02:01:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1361977292; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:Mail-Followup-To:MIME-Version: Content-Type:Content-Disposition:User-Agent:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=a3F6fiMcLP5FHW2QKV5jdaYLIEw=; b=cN1MRi37CmjADgJHTeP6D0LOPrJ8gTzNAFQ+y66kBoTpzHsW+WHlkzgsER/bCN T9phcllL2l9wTu1b6oUeaNaiHMwdmba4Kpk1yJI6b7ikTDiKnGUWGtO8bvzteKEU aacAIAa398fMfsKVRHVdfCuuJ++D8G6h2rroZ8vy/dDdE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=k0mtpZyuhD57pL3j2hVAMt40ngy4cKOVu7iSPGxGVcmaQxpKpG+8l4rFAdvcYt 9i4U5W3utBnpRAHjwreQtOluOTvLxsPvJ9R2XhjA5rz7WUENzwWrGTapANfBGqkf PfNVF0rAd8fpTADJoVg+yEJF6OtGeRbP6QXOQ8moFcNjE=; Received: (qmail 25538 invoked by alias); 20 Feb 2013 15:01:18 -0000 Received: (qmail 25494 invoked by uid 22791); 20 Feb 2013 15:01:15 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Feb 2013 15:01:07 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A1CDFA51FE; Wed, 20 Feb 2013 16:01:06 +0100 (CET) Date: Wed, 20 Feb 2013 16:01:04 +0100 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, PR 56294] Fix omissions in intersect_aggregates_with_edge Message-ID: <20130220150104.GE19120@virgil.suse> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi, this patch fixes an omission in IPA-CP's agg_replacements_to_vector which needs to filter the vector by index and offset and a typo in intersect_aggregates_with_edge which in one call passed the wrong index to agg_replacements_to_vector. This combined lead to empty intersections which were caught by an assert checking exactly that. Bootstrapped and tested on x86_64-linux (all languages + Ada) with default BOOT_CFLAGS and also with BOOT_CFLAGS='-O2 -g -fipa-cp-clone --param=ipa-cp-eval-threshold=100' (C, C++ and Fortran only), I'm currently bootstrapping with the param set to 1. OK for trunk? Thanks, Martin 2013-02-19 Martin Jambor PR tree-optimization/56310 * ipa-cp.c (agg_replacements_to_vector): New parameter index, copy only matching indices and non-negative final offsets. (intersect_aggregates_with_edge): Pass src_idx to agg_replacements_to_vector. Pass src_idx insstead of index to intersect_with_agg_replacements. testsuite/ * g++.dg/ipa/pr56310.C: New test. Index: src/gcc/ipa-cp.c =================================================================== --- src.orig/gcc/ipa-cp.c +++ src/gcc/ipa-cp.c @@ -2807,12 +2807,15 @@ intersect_with_plats (struct ipcp_param_ vector result while subtracting OFFSET from the individual value offsets. */ static vec -agg_replacements_to_vector (struct cgraph_node *node, HOST_WIDE_INT offset) +agg_replacements_to_vector (struct cgraph_node *node, int index, + HOST_WIDE_INT offset) { struct ipa_agg_replacement_value *av; vec res = vNULL; for (av = ipa_get_agg_replacements_for_node (node); av; av = av->next) + if (av->index == index + && (av->offset - offset) >= 0) { struct ipa_agg_jf_item item; gcc_checking_assert (av->value); @@ -2892,7 +2895,7 @@ intersect_aggregates_with_edge (struct c if (agg_pass_through_permissible_p (orig_plats, jfunc)) { if (!inter.exists ()) - inter = agg_replacements_to_vector (cs->caller, 0); + inter = agg_replacements_to_vector (cs->caller, src_idx, 0); else intersect_with_agg_replacements (cs->caller, src_idx, &inter, 0); @@ -2925,9 +2928,9 @@ intersect_aggregates_with_edge (struct c if (caller_info->ipcp_orig_node) { if (!inter.exists ()) - inter = agg_replacements_to_vector (cs->caller, delta); + inter = agg_replacements_to_vector (cs->caller, src_idx, delta); else - intersect_with_agg_replacements (cs->caller, index, &inter, + intersect_with_agg_replacements (cs->caller, src_idx, &inter, delta); } else Index: src/gcc/testsuite/g++.dg/ipa/pr56310.C =================================================================== --- /dev/null +++ src/gcc/testsuite/g++.dg/ipa/pr56310.C @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fipa-cp -std=gnu++0x -fno-early-inlining -fipa-cp-clone --param=ipa-cp-eval-threshold=1" } */ + +void bar (void *, void *); + +struct C +{ + constexpr C ():p (0) + { + } + void *get () + { + return p; + } + void *p; +}; + +struct B:C +{ +}; + +struct A +{ + void f (B * x, B * y) + { + bar (x->get (), y->get ()); + } +}; + +void +foo () +{ + A a; + B b; + a.f (&b, &b); +}