From patchwork Wed Aug 9 11:39:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 799679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-460095-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZdIlD0zA"; dkim-atps=neutral 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 3xS8Sm74Xfz9s82 for ; Wed, 9 Aug 2017 21:39:52 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=W98q85ygYjWykSeBK hutyhIAGRH/ht9osjzDcPJTHYfuTkT+seAa7Cx4ciho/tFR7Od/lgMbiXGdjxLnY kAas/nhIrKOOLJO+5k+awN7VHa5clUkXI1ZfzxTVhnMMh5QHfnjIodq7F7mhrwyx 80PATL2T757bRZ9Rrb6Fd6yfi0= 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 :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=3euKgalUTzPVcTBzrCyiINN riCg=; b=ZdIlD0zAwiwhr77GtDGppQdkhCiryfFSQzp2N+WFhJ2yjWz655r3Su4 snPsMLFzJopJIFuWGeXH96T7F89m/9Yoyc7ycAErUgs8Jjuvwdt+JF+e/XxsxsIS UcIdX8XLHybfIQo9MAL9hh6BYAK4b9+1Ffx13I+YUehGZXAyIjuQ= Received: (qmail 57111 invoked by alias); 9 Aug 2017 11:39:37 -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 57039 invoked by uid 89); 9 Aug 2017 11:39:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=7307 X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Aug 2017 11:39:31 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 984D1ABDD; Wed, 9 Aug 2017 11:39:25 +0000 (UTC) Subject: Re: [PATCH] Convert character arrays to string csts To: Richard Biener Cc: Jan Hubicka , Bernd Schmidt , GCC Patches References: <1a50afaa-6b8e-ba98-6cde-aae51c05a2c4@suse.cz> <1b1f844f-a20d-4702-27ea-59d718b8a99e@redhat.com> <20161103130057.GD52446@kam.mff.cuni.cz> <749c0fce-2c35-7f02-e130-7f04a4260ebf@suse.cz> <6adfa5f6-5576-9eee-2656-b2d25d0397f3@suse.cz> <5a0bd904-c8e5-da15-7411-44d297613121@suse.cz> <5157906E-0A85-46D6-99AE-63F48546418D@gmail.com> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: Date: Wed, 9 Aug 2017 13:39:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <5157906E-0A85-46D6-99AE-63F48546418D@gmail.com> X-IsSubscribed: yes On 08/09/2017 11:43 AM, Richard Biener wrote: > I only have the patch I sent you so I can't re-diff. > > Richard. Hi. I'm sending rebased version of the patch. However the patch eats all my memory when e.g. building ../../../libgcc/libgcov-merge.c. If you have time, please try to make it working for &STRING_CST. I can continue then. Thanks, Martin diff --git a/gcc/gimple-expr.c b/gcc/gimple-expr.c index c1771fcf1d0..eb22456c241 100644 --- a/gcc/gimple-expr.c +++ b/gcc/gimple-expr.c @@ -631,7 +631,7 @@ is_gimple_address (const_tree t) op = TREE_OPERAND (op, 0); } - if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF) + if (TREE_CODE (op) == MEM_REF) return true; switch (TREE_CODE (op)) @@ -667,11 +667,10 @@ is_gimple_invariant_address (const_tree t) { const_tree op0 = TREE_OPERAND (op, 0); return (TREE_CODE (op0) == ADDR_EXPR - && (CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)) - || decl_address_invariant_p (TREE_OPERAND (op0, 0)))); + && decl_address_invariant_p (TREE_OPERAND (op0, 0))); } - return CONSTANT_CLASS_P (op) || decl_address_invariant_p (op); + return decl_address_invariant_p (op); } /* Return true if T is a gimple invariant address at IPA level @@ -693,11 +692,10 @@ is_gimple_ip_invariant_address (const_tree t) { const_tree op0 = TREE_OPERAND (op, 0); return (TREE_CODE (op0) == ADDR_EXPR - && (CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)) - || decl_address_ip_invariant_p (TREE_OPERAND (op0, 0)))); + && decl_address_ip_invariant_p (TREE_OPERAND (op0, 0))); } - return CONSTANT_CLASS_P (op) || decl_address_ip_invariant_p (op); + return decl_address_ip_invariant_p (op); } /* Return true if T is a GIMPLE minimal invariant. It's a restricted @@ -732,7 +730,7 @@ is_gimple_reg (tree t) if (virtual_operand_p (t)) return false; - if (TREE_CODE (t) == SSA_NAME) + if (TREE_CODE (t) == SSA_NAME || TREE_CODE (t) == CONST_DECL) return true; if (!is_gimple_variable (t)) @@ -825,8 +823,7 @@ is_gimple_mem_ref_addr (tree t) return (is_gimple_reg (t) || TREE_CODE (t) == INTEGER_CST || (TREE_CODE (t) == ADDR_EXPR - && (CONSTANT_CLASS_P (TREE_OPERAND (t, 0)) - || decl_address_invariant_p (TREE_OPERAND (t, 0))))); + && decl_address_invariant_p (TREE_OPERAND (t, 0)))); } /* Hold trees marked addressable during expand. */ diff --git a/gcc/gimple-expr.h b/gcc/gimple-expr.h index 6e969164a37..04de209c092 100644 --- a/gcc/gimple-expr.h +++ b/gcc/gimple-expr.h @@ -94,9 +94,7 @@ is_gimple_id (tree t) return (is_gimple_variable (t) || TREE_CODE (t) == FUNCTION_DECL || TREE_CODE (t) == LABEL_DECL - || TREE_CODE (t) == CONST_DECL - /* Allow string constants, since they are addressable. */ - || TREE_CODE (t) == STRING_CST); + || TREE_CODE (t) == CONST_DECL); } /* Return true if OP, an SSA name or a DECL is a virtual operand. */ diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 86623e09f5d..d56d1dfe8ab 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2871,7 +2871,8 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, so as to match the min_lval predicate. Failure to do so may result in the creation of large aggregate temporaries. */ tret = gimplify_expr (p, pre_p, post_p, is_gimple_min_lval, - fallback | fb_lvalue); + expr_stack.length () > 0 + ? fb_lvalue : fallback | fb_lvalue); ret = MIN (ret, tret); /* And finally, the indices and operands of ARRAY_REF. During this @@ -11503,7 +11504,17 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, that in the GIMPLE IL. */ if (TREE_OVERFLOW_P (*expr_p)) *expr_p = drop_tree_overflow (*expr_p); - ret = GS_ALL_DONE; + + if (fallback & fb_rvalue) + ret = GS_ALL_DONE; + else + { + tree cdecl = build_decl (UNKNOWN_LOCATION, CONST_DECL, + NULL_TREE, TREE_TYPE (*expr_p)); + DECL_INITIAL (cdecl) = *expr_p; + *expr_p = cdecl; + ret = GS_OK; + } break; case CONST_DECL: