From patchwork Tue Apr 30 12:00:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 240604 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 5BED52C00BF for ; Tue, 30 Apr 2013 22:00:31 +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:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=qCFCJiGShUpyvsr56VufjLVtY/OkUc NeAzM6a7o2C30S9ufwbdSPUwkK3cxYg+kJplIwbhgGvkwgp9OFwgaj0zWcDGOD0P uVgFnK26koHSpKs1vkmOuZsdOjPByItT7kQ61pOiC5N3fFdvIWxG6rzO3Ehc50sT pc/SGP3ZRPRSY= 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:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=klTcWjuvvlI9G2gENe1XXDm08lo=; b=pDlu +dnpNYDRoymCmY714L9BK9lwYjWPsQDkp0Tc1UuvWXG9eB98+j8cGdhVMht65T5L jVNcjaPJ/AVIAsOlvV6hntBeulTGOckWBheO6WrGcYwRe9eM2ZBIaDgCRoNaRYD0 dPGq/KmcUj/d6KdqVAa+610jLaY0Jtmm9W98XiY= Received: (qmail 31866 invoked by alias); 30 Apr 2013 12:00:24 -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 31855 invoked by uid 89); 30 Apr 2013 12:00:24 -0000 X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, TW_GG, TW_GJ autolearn=no version=3.3.1 Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 30 Apr 2013 12:00:23 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id ADD41A535C; Tue, 30 Apr 2013 14:00:21 +0200 (CEST) Date: Tue, 30 Apr 2013 14:00:21 +0200 From: Martin Jambor To: GCC Patches , Jan Hubicka Subject: Ping: [PATCH, PR 56988] Honor by_ref in IPA-CP transformation phase Message-ID: <20130430120021.GB3544@virgil.suse> Mail-Followup-To: GCC Patches , Jan Hubicka References: <20130419090558.GB5129@virgil.suse> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130419090558.GB5129@virgil.suse> User-Agent: Mutt/1.5.21 (2010-09-15) Ping. Thanks, Martin ----- Forwarded message from Martin Jambor ----- Date: Fri, 19 Apr 2013 11:05:58 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, PR 56988] Honor by_ref in IPA-CP transformation phase Hi, the following patch fixes PR 56988 by distinguishing between by reference and by value aggregate replacement value. While it is OK to ignore the difference in the last phases of propagation/decision making because any discrepancies have already been weeded out there, the testcase clearly shows we have to make sure we do not confuse the two when looking at the statements again. Bootstrapped and tested on trunk on x86_64-linux. OK for trunk now and for the 4.8 branch after a round of testing there? Thanks, Martin 2013-04-18 Martin Jambor PR middle-end/56988 * ipa-prop.h (ipa_agg_replacement_value): New flag by_ref. * ipa-cp.c (ipa_get_indirect_edge_target_1): Also check that by_ref flags match. (find_aggregate_values_for_callers_subset): Fill in the by_ref flag of ipa_agg_replacement_value structures. (known_aggs_to_agg_replacement_list): Likewise. * ipa-prop.c (write_agg_replacement_chain): Stream by_ref flag. (read_agg_replacement_chain): Likewise. (ipcp_transform_function): Also check that by_ref flags match. testsuite/ * gcc.dg/ipa/pr56988.c: New test. ----- End forwarded message ----- Index: src/gcc/ipa-cp.c =================================================================== --- src.orig/gcc/ipa-cp.c +++ src/gcc/ipa-cp.c @@ -1508,7 +1508,8 @@ ipa_get_indirect_edge_target_1 (struct c while (agg_reps) { if (agg_reps->index == param_index - && agg_reps->offset == ie->indirect_info->offset) + && agg_reps->offset == ie->indirect_info->offset + && agg_reps->by_ref == ie->indirect_info->by_ref) { t = agg_reps->value; break; @@ -3042,11 +3043,12 @@ find_aggregate_values_for_callers_subset struct cgraph_edge *cs; vec inter = vNULL; struct ipa_agg_jf_item *item; + struct ipcp_param_lattices *plats = ipa_get_parm_lattices (dest_info, i); int j; /* Among other things, the following check should deal with all by_ref mismatches. */ - if (ipa_get_parm_lattices (dest_info, i)->aggs_bottom) + if (plats->aggs_bottom) continue; FOR_EACH_VEC_ELT (callers, j, cs) @@ -3068,6 +3070,7 @@ find_aggregate_values_for_callers_subset v->index = i; v->offset = item->offset; v->value = item->value; + v->by_ref = plats->aggs_by_ref; v->next = res; res = v; } @@ -3097,6 +3100,7 @@ known_aggs_to_agg_replacement_list (vec< v->index = i; v->offset = item->offset; v->value = item->value; + v->by_ref = aggjf->by_ref; v->next = res; res = v; } Index: src/gcc/ipa-prop.c =================================================================== --- src.orig/gcc/ipa-prop.c +++ src/gcc/ipa-prop.c @@ -3674,9 +3674,15 @@ write_agg_replacement_chain (struct outp for (av = aggvals; av; av = av->next) { + struct bitpack_d bp; + streamer_write_uhwi (ob, av->offset); streamer_write_uhwi (ob, av->index); stream_write_tree (ob, av->value, true); + + bp = bitpack_create (ob->main_stream); + bp_pack_value (&bp, av->by_ref, 1); + streamer_write_bitpack (&bp); } } @@ -3694,11 +3700,14 @@ read_agg_replacement_chain (struct lto_i for (i = 0; i offset = streamer_read_uhwi (ib); av->index = streamer_read_uhwi (ib); av->value = stream_read_tree (ib, data_in); + bp = streamer_read_bitpack (ib); + av->by_ref = bp_unpack_value (&bp, 1); av->next = aggvals; aggvals = av; } @@ -3917,7 +3926,7 @@ ipcp_transform_function (struct cgraph_n if (v->index == index && v->offset == offset) break; - if (!v) + if (!v || v->by_ref != by_ref) continue; gcc_checking_assert (is_gimple_ip_invariant (v->value)); Index: src/gcc/ipa-prop.h =================================================================== --- src.orig/gcc/ipa-prop.h +++ src/gcc/ipa-prop.h @@ -386,6 +386,8 @@ struct GTY(()) ipa_agg_replacement_value tree value; /* The paramter index. */ int index; + /* Whether the value was passed by reference. */ + bool by_ref; }; typedef struct ipa_agg_replacement_value *ipa_agg_replacement_value_p; Index: src/gcc/testsuite/gcc.dg/ipa/pr56988.c =================================================================== --- /dev/null +++ src/gcc/testsuite/gcc.dg/ipa/pr56988.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-add-options bind_pic_locally } */ + +struct S +{ + int a, b, c; +}; + +volatile int g; + +static void __attribute__ ((noinline, noclone)) +bar (struct S **p) +{ + g = 5; +}; + +static void __attribute__ ((noinline)) +foo (struct S *p) +{ + int i = p->a; + if (i != 1) + __builtin_abort (); + bar (&p); +} + +int +main (int argc, char *argv[]) +{ + struct S s; + s.a = 1; + s.b = 64; + s.c = 32; + foo (&s); + + return 0; +} +