From patchwork Wed Oct 24 09:09:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 193712 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 1D60F2C008A for ; Wed, 24 Oct 2012 20:10:12 +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=1351674613; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=BzEH3UdEJmey+nkPkXP3ROo982I=; b=sqGmpHnO4Rtp8Fn BsjCb017tOMbx/BGo0zSsavcQTkpJ89pyCBCJ+zcYwawuRrtwbX4oKzd0ffGjJNV Bpfvm+80CRaefBOXw2M0HWAT2MdjvELiOFCaxsnu13S4Hpi3xZU1ismyjJ5Tcjo/ IbuWMZvkwDMjRHGX6+9VXflyDeZw= 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:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=E76QSOThsr8RmyfjxwBibr1zyu4L/nplX3mUelVHvsQH32oABEiV4iqFjNzhRx szEnQmyc0JEqF2vXhV6bw0pE5jqefAPLcEIvh1poRViLxCwkIRAAoGfyIxPKHmc4 /WZ88nbhgM64oC2GR3iCGcjbdIxPVssQKX5NNuuB/uzL0=; Received: (qmail 20073 invoked by alias); 24 Oct 2012 09:10:04 -0000 Received: (qmail 20029 invoked by uid 22791); 24 Oct 2012 09:10:03 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 24 Oct 2012 09:09:54 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9O99r4G010329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 24 Oct 2012 05:09:53 -0400 Received: from zalov.redhat.com (vpn1-5-133.ams2.redhat.com [10.36.5.133]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9O99qgj025931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Oct 2012 05:09:53 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id q9O99pDf032413; Wed, 24 Oct 2012 11:09:51 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id q9O99pOm032412; Wed, 24 Oct 2012 11:09:51 +0200 Date: Wed, 24 Oct 2012 11:09:50 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] variably_modified_type_p tweak for cdtor cloning (PR debug/54828) Message-ID: <20121024090950.GB1752@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20121023155053.GS1752@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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 On Wed, Oct 24, 2012 at 10:35:33AM +0200, Richard Biener wrote: > Can you factor this and the variant in gimplify_one_sizepos out into > a predicate? Like is_gimple_sizepos ()? > > Ok with that change. Here is what I've committed: 2012-10-24 Jakub Jelinek PR debug/54828 * gimple.h (is_gimple_sizepos): New inline function. * gimplify.c (gimplify_one_sizepos): Use it. Remove useless final assignment to expr variable. * tree.c (RETURN_TRUE_IF_VAR): Return true also if !TYPE_SIZES_GIMPLIFIED (type) and _t is going to be gimplified into a local temporary. * g++.dg/debug/pr54828.C: New test. Jakub --- gcc/gimple.h.jj 2012-10-23 18:52:10.000000000 +0200 +++ gcc/gimple.h 2012-10-24 10:48:50.062669054 +0200 @@ -957,6 +957,24 @@ struct gimplify_ctx bool in_cleanup_point_expr; }; +/* Return true if gimplify_one_sizepos doesn't need to gimplify + expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize + fields). */ +static inline bool +is_gimple_sizepos (tree expr) +{ + /* gimplify_one_sizepos doesn't need to do anything if the value isn't there, + is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do + anything if it's already a VAR_DECL. If it's a VAR_DECL from another + function, the gimplifier will want to replace it with a new variable, + but that will cause problems if this type is from outside the function. + It's OK to have that here. */ + return (expr == NULL_TREE + || TREE_CONSTANT (expr) + || TREE_CODE (expr) == VAR_DECL + || CONTAINS_PLACEHOLDER_P (expr)); +} + extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *, bool (*) (tree), fallback_t); extern void gimplify_type_sizes (tree, gimple_seq *); --- gcc/gimplify.c.jj 2012-10-17 17:18:21.000000000 +0200 +++ gcc/gimplify.c 2012-10-24 10:50:07.032204700 +0200 @@ -8147,15 +8147,12 @@ gimplify_one_sizepos (tree *expr_p, gimp a VAR_DECL. If it's a VAR_DECL from another function, the gimplifier will want to replace it with a new variable, but that will cause problems if this type is from outside the function. It's OK to have that here. */ - if (expr == NULL_TREE || TREE_CONSTANT (expr) - || TREE_CODE (expr) == VAR_DECL - || CONTAINS_PLACEHOLDER_P (expr)) + if (is_gimple_sizepos (expr)) return; *expr_p = unshare_expr (expr); gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue); - expr = *expr_p; } /* Gimplify the body of statements of FNDECL and return a GIMPLE_BIND node --- gcc/tree.c.jj 2012-10-23 18:52:03.455219291 +0200 +++ gcc/tree.c 2012-10-24 10:51:51.483574589 +0200 @@ -8467,14 +8467,19 @@ variably_modified_type_p (tree type, tre tree t; /* Test if T is either variable (if FN is zero) or an expression containing - a variable in FN. */ + a variable in FN. If TYPE isn't gimplified, return true also if + gimplify_one_sizepos would gimplify the expression into a local + variable. */ #define RETURN_TRUE_IF_VAR(T) \ do { tree _t = (T); \ if (_t != NULL_TREE \ && _t != error_mark_node \ && TREE_CODE (_t) != INTEGER_CST \ && TREE_CODE (_t) != PLACEHOLDER_EXPR \ - && (!fn || walk_tree (&_t, find_var_from_fn, fn, NULL))) \ + && (!fn \ + || (!TYPE_SIZES_GIMPLIFIED (type) \ + && !is_gimple_sizepos (_t)) \ + || walk_tree (&_t, find_var_from_fn, fn, NULL))) \ return true; } while (0) if (type == error_mark_node) --- gcc/testsuite/g++.dg/debug/pr54828.C.jj 2012-10-24 10:44:31.179231097 +0200 +++ gcc/testsuite/g++.dg/debug/pr54828.C 2012-10-24 10:44:31.180231091 +0200 @@ -0,0 +1,14 @@ +// PR debug/54828 +// { dg-do compile } +// { dg-options "-g" } + +struct T { T (); virtual ~T (); }; +struct S : public virtual T { S (); virtual ~S (); }; +int v; +void foo (char *); + +S::S () +{ + char s[v]; + foo (s); +}