From patchwork Wed Sep 3 08:46:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 385437 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 66CFF1400DE for ; Wed, 3 Sep 2014 18:49:24 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=ZkQIL8VS3R8Mkj3phC+z/LBUsp3e0HKufQWP4h52bbnj7c3Zgz Xs9Rv6iWWTHIwud2y+FaMmSqUXIE3QNv6f3IWUQttXeKY+jjVx/uHoEUDfu4DmJx qRKm7THjNbEmTrlg05d7tKqbsCy6MYB9s9nxz1z+RS8lCEPVEGpVWlHf0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=EIf91Kun+wDBN8ekzEcQpbQe+mo=; b=Aq2OAv2hMw7CMmXqByFk TV4URZgHBM3MsgncwLHIX5uRqNjVwQH0uvfyhg9SlPaQqex/dwUwGm+YJ0N8Luwp yKKv2r7ExU5K0glpM61RS6Bmx1P60A2/tPTPTYVzggueFQ5jGJEHuDhdszotk/rz FSW56UA1dPxzrAvr9zjOo1k= Received: (qmail 13476 invoked by alias); 3 Sep 2014 08:47:05 -0000 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 Received: (qmail 13465 invoked by uid 89); 3 Sep 2014 08:47:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 03 Sep 2014 08:46:57 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5048CAC9A; Wed, 3 Sep 2014 08:46:54 +0000 (UTC) Date: Wed, 3 Sep 2014 10:46:54 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, PR 61986] Produce aggregate replacement nodes in ascending order of offsets Message-ID: <20140903084653.GC18073@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 Hi, intersecting known aggregate values coming along a given set of call graph edges requires that all lists are in ascending order of offsets in order to perform it in only one sweep through each of them. However, aggregate replacement nodes are produced in exactly the opposite order. This makes us miss an item in the intersection and assert later. The ordering is fixed by the following patch. Bootstrapped and tested on x86_64-linux. OK for the trunk and all problematic branches (4.9 for sure, I am not sure about 4.8 at this moment). Thanks, Martin 2014-09-02 Martin Jambor PR ipa/61986 * ipa-cp.c (find_aggregate_values_for_callers_subset): Chain created replacements in ascending order of offsets. (known_aggs_to_agg_replacement_list): Likewise. testsuite/ * gcc.dg/ipa/pr61986.c: New test. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 44d4c9a..58121d4 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -3146,7 +3146,8 @@ find_aggregate_values_for_callers_subset (struct cgraph_node *node, vec callers) { struct ipa_node_params *dest_info = IPA_NODE_REF (node); - struct ipa_agg_replacement_value *res = NULL; + struct ipa_agg_replacement_value *res; + struct ipa_agg_replacement_value **tail = &res; struct cgraph_edge *cs; int i, j, count = ipa_get_param_count (dest_info); @@ -3190,14 +3191,15 @@ find_aggregate_values_for_callers_subset (struct cgraph_node *node, v->offset = item->offset; v->value = item->value; v->by_ref = plats->aggs_by_ref; - v->next = res; - res = v; + *tail = v; + tail = &v->next; } next_param: if (inter.exists ()) inter.release (); } + *tail = NULL; return res; } @@ -3206,7 +3208,8 @@ find_aggregate_values_for_callers_subset (struct cgraph_node *node, static struct ipa_agg_replacement_value * known_aggs_to_agg_replacement_list (vec known_aggs) { - struct ipa_agg_replacement_value *res = NULL; + struct ipa_agg_replacement_value *res; + struct ipa_agg_replacement_value **tail = &res; struct ipa_agg_jump_function *aggjf; struct ipa_agg_jf_item *item; int i, j; @@ -3220,9 +3223,10 @@ known_aggs_to_agg_replacement_list (vec known_aggs) v->offset = item->offset; v->value = item->value; v->by_ref = aggjf->by_ref; - v->next = res; - res = v; + *tail = v; + tail = &v->next; } + *tail = NULL; return res; } diff --git a/gcc/testsuite/gcc.dg/ipa/pr61986.c b/gcc/testsuite/gcc.dg/ipa/pr61986.c new file mode 100644 index 0000000..8d2f658 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr61986.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b, c; + +struct S +{ + int f0; + int f1; +} d; + +static int fn2 (struct S); +void fn3 (struct S); + +void +fn1 (struct S p) +{ + struct S h = { 0, 0 }; + fn3 (p); + fn2 (h); +} + +int +fn2 (struct S p) +{ + struct S j = { 0, 0 }; + fn3 (p); + fn2 (j); + return 0; +} + +void +fn3 (struct S p) +{ + for (; b; a++) + c = p.f0; + fn1 (d); +} + +void +fn4 () +{ + for (;;) + { + struct S f = { 0, 0 }; + fn1 (f); + } +}