From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1188 invoked by alias); 11 Jul 2008 18:17:53 -0000 Received: (qmail 1177 invoked by uid 22791); 11 Jul 2008 18:17:52 -0000 X-Spam-Check-By: sourceware.org Received: from province.act-europe.fr (HELO province.act-europe.fr) (212.99.106.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 11 Jul 2008 18:17:33 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-province.act-europe.fr (Postfix) with ESMTP id 52426165F81; Fri, 11 Jul 2008 20:17:29 +0200 (CEST) Received: from province.act-europe.fr ([127.0.0.1]) by localhost (province.act-europe.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rNJECyCjzsY4; Fri, 11 Jul 2008 20:17:29 +0200 (CEST) Received: from [192.168.1.3] (dyn-88-122-74-34.ppp.tiscali.fr [88.122.74.34]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by province.act-europe.fr (Postfix) with ESMTPSA id E4C7B165E5D; Fri, 11 Jul 2008 20:17:28 +0200 (CEST) From: Eric Botcazou To: "Richard Guenther" Subject: Re: refinements to definition of TREE_READONLY ? Date: Fri, 11 Jul 2008 18:42:00 -0000 User-Agent: KMail/1.7.1 Cc: gcc@gcc.gnu.org, "Olivier Hainque" References: <20080711161512.GA24187@cardhu.act-europe.fr> <20080711172259.GA2627@cardhu.act-europe.fr> <84fc9c000807111035v528dc617od032ebb8acee1807@mail.gmail.com> In-Reply-To: <84fc9c000807111035v528dc617od032ebb8acee1807@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200807112017.33833.ebotcazou@adacore.com> Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2008-07/txt/msg00216.txt.bz2 > For static storage yes, which it seems to test: > > else if (TREE_CODE (rhs) == VAR_DECL > && TREE_STATIC (rhs) > && TREE_READONLY (rhs) > && targetm.binds_local_p (rhs)) > fns->init (lhs_elt, DECL_INITIAL (rhs), bsi); I think there is a problem with binds_local_p though, which explains why PR tree-opt/35493 has been fixed for ELF but not for PE-COFF (PR ada/36207): what if we have DECL_EXTERNAL, targetm.binds_local_p and no DECL_INITIAL? In this case, the code will replace the VAR_DECL with zero, which is wrong. tree-ssa-ccp.c:get_symbol_constant_value will do the same. For example, expand_expr_real_1 does test the non-nullity of DECL_INITIAL: else if (optimize >= 1 && modifier != EXPAND_CONST_ADDRESS && modifier != EXPAND_INITIALIZER && modifier != EXPAND_MEMORY && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array) && TREE_CODE (array) == VAR_DECL && DECL_INITIAL (array) && TREE_CODE (DECL_INITIAL (array)) != ERROR_MARK && targetm.binds_local_p (array)) Here's the hook for PE-COFF: bool i386_pe_binds_local_p (const_tree exp) { /* PE does not do dynamic binding. Indeed, the only kind of non-local reference comes from a dllimport'd symbol. */ if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL) && DECL_DLLIMPORT_P (exp)) return false; return true; } -- Eric Botcazou