From patchwork Thu Dec 9 10:23:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 74866 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 D69D5B70A7 for ; Thu, 9 Dec 2010 21:23:26 +1100 (EST) Received: (qmail 28105 invoked by alias); 9 Dec 2010 10:23:24 -0000 Received: (qmail 28096 invoked by uid 22791); 9 Dec 2010 10:23:23 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Dec 2010 10:23:19 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 83DE299E14 for ; Thu, 9 Dec 2010 11:23:16 +0100 (CET) Date: Thu, 9 Dec 2010 11:23:16 +0100 From: Martin Jambor To: GCC Patches Cc: Richard Guenther Subject: [PATCH, PR 46734, 4.5, 4.6] No TREE_ADDRESSIBLE types conversion in IPA-SRA Message-ID: <20101209102315.GA10989@virgil.arch.suse.de> Mail-Followup-To: GCC Patches , Richard Guenther MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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, doing type conversion of TREE_ADDRESSIBLE basically requires keeping the old aggregate around which beats the purpose of IPA-SRA. The fix is therefore to disallow such conversions when aggregating accesses. The patch below has been generated from trunk but the same patch applies to the 4.5 branch too and fixes the problem there as well. I have bootstrapped and tested it on both the trunk and the branch on x86_64-linux. OK for trunk now and for the 4.5 branch once it is unfrozen? Thanks, Martin 2010-12-08 Martin Jambor PR middle-end/46734 * tree-sra.c (splice_param_accesses): Check that there are not multiple ADDRESSABLE types. * testsuite/g++.dg/tree-ssa/pr46734.C: New test. Index: mine/gcc/testsuite/g++.dg/tree-ssa/pr46734.C =================================================================== --- /dev/null +++ mine/gcc/testsuite/g++.dg/tree-ssa/pr46734.C @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fipa-sra" } */ + +struct A +{ + int *p; + A() {p = (int *) -1;} + ~A() {if (p && p != (int *) -1) *p = 0;} +}; + +struct B +{ + A a; + char data[23]; + B() : a() {data[0] = 0;} +}; + +extern A ga; +extern int *gi; +extern void *gz; +extern B *gb; + +static int * __attribute__ ((noinline)) foo (B *b, void *z) +{ + __builtin_memcpy (gz, z, 28); + ga = b->a; + return b->a.p; +} + +int *bar (B *b, void *z) +{ + gb = b; + return foo (b, z); +} Index: mine/gcc/tree-sra.c =================================================================== --- mine.orig/gcc/tree-sra.c +++ mine/gcc/tree-sra.c @@ -3587,7 +3587,10 @@ splice_param_accesses (tree parm, bool * else if (ac2->size != access->size) return NULL; - if (access_precludes_ipa_sra_p (ac2)) + if (access_precludes_ipa_sra_p (ac2) + || (ac2->type != access->type + && (TREE_ADDRESSABLE (ac2->type) + || TREE_ADDRESSABLE (access->type)))) return NULL; modification |= ac2->write;