From patchwork Sat Sep 4 16:23:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 63797 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 BD106B714A for ; Sun, 5 Sep 2010 02:23:17 +1000 (EST) Received: (qmail 8809 invoked by alias); 4 Sep 2010 16:23:13 -0000 Received: (qmail 8796 invoked by uid 22791); 4 Sep 2010 16:23:12 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_FR, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Sep 2010 16:23:07 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id DD4529ACA90; Sat, 4 Sep 2010 18:23:04 +0200 (CEST) Date: Sat, 4 Sep 2010 18:23:04 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Update string_constant for new const initializer code Message-ID: <20100904162304.GD31380@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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, while disabling initializer folding in expr.c I noticed that string-constant is actually used by builtin folding and thus it needs to be updated for new varppol initializer code. Unfortunately folding also happens early from frntend and thus we need to behave sanely when varpool is not ready yet. The patch removes TREE_SIDE_EFFECTS check since we don't do it elsewhere (and I have problems to think of volatile constant string having some meaning) and also makes us to use DECL_REPLACEABLE_P instead of targetm.binds_local_p like we do elsewhere now too. Bootstrapped/regtested x86_64-linx, OK? Honza * expr.c (string_constant): Use varpool to figure out if value is known. Index: expr.c =================================================================== --- expr.c (revision 163859) +++ expr.c (working copy) @@ -9815,10 +9837,12 @@ string_constant (tree arg, tree *ptr_off || TREE_CODE (DECL_INITIAL (array)) != STRING_CST) return 0; - /* If they are read-only, non-volatile and bind locally. */ + /* If they are read-only and non-replaceable. */ if (! TREE_READONLY (array) - || TREE_SIDE_EFFECTS (array) - || ! targetm.binds_local_p (array)) + || ((!cgraph_function_flags_ready + && !DECL_REPLACEABLE_P (array)) + || (cgraph_function_flags_ready + && !varpool_get_node (array)->const_value_known))) return 0; /* Avoid const char foo[4] = "abcde"; */