From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32363 invoked by alias); 16 Oct 2004 00:57:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 32333 invoked from network); 16 Oct 2004 00:57:30 -0000 Received: from unknown (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org with SMTP; 16 Oct 2004 00:57:30 -0000 Received: from camelot.ms.mff.cuni.cz (kampanus.ms.mff.cuni.cz [195.113.18.107]) by nikam.ms.mff.cuni.cz (Postfix) with SMTP id 588294E3BF; Sat, 16 Oct 2004 02:57:32 +0200 (CEST) Received: by camelot.ms.mff.cuni.cz (sSMTP sendmail emulation); Sat, 16 Oct 2004 02:57:35 +0200 Date: Sat, 16 Oct 2004 01:03:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rth@redhat.com, gcc@gcc.gnu.org Subject: Dubious code in check_global_declarations Message-ID: <20041016005735.GH9118@kam.mff.cuni.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i X-SW-Source: 2004-10/txt/msg01318.txt.bz2 Hi, check_global_declarations contains a code that unconditionally clears DECL_RTL of all static variables. I have problems to follow the comment probably explaining the rationalle of this. My problem is that this code has counterpart in rest_of_decl_compilation that makes these variables to bypass cgraph confusing any attempts to do IPA on variables. This is very common problem for java where DECL_RTL is set for some datastructures produced by the frontend. I've bootstrapped and regtested the attached patch to kill both hacks on i686-pc-gnu-linux without problems. Can someone shed more light on this issue or would be the patch OK for mainline? Honza 2004-10-16 Jan Hubicka * passes.c (rest_of_decl_compilation): Kill hack carring about DECL_RTL_SET_P * toplev.c (check_global_declarations): Do not clear DECL_RTL. Index: passes.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/passes.c,v retrieving revision 2.52 diff -c -3 -p -r2.52 passes.c *** passes.c 25 Sep 2004 10:05:09 -0000 2.52 --- passes.c 15 Oct 2004 14:56:50 -0000 *************** rest_of_decl_compilation (tree decl, *** 229,242 **** && !DECL_EXTERNAL (decl)) { if (flag_unit_at_a_time && !cgraph_global_info_ready ! && TREE_CODE (decl) != FUNCTION_DECL && top_level ! /* If we defer processing of decls that have had their ! DECL_RTL set above (say, in make_decl_rtl), ! check_global_declarations() will clear it before ! assemble_variable has a chance to act on it. This ! would remove all traces of the register name in a ! global register variable, for example. */ ! && !DECL_RTL_SET_P (decl)) cgraph_varpool_finalize_decl (decl); else assemble_variable (decl, top_level, at_end, 0); --- 229,235 ---- && !DECL_EXTERNAL (decl)) { if (flag_unit_at_a_time && !cgraph_global_info_ready ! && TREE_CODE (decl) != FUNCTION_DECL && top_level) cgraph_varpool_finalize_decl (decl); else assemble_variable (decl, top_level, at_end, 0); Index: toplev.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/toplev.c,v retrieving revision 1.928 diff -c -3 -p -r1.928 toplev.c *** toplev.c 13 Oct 2004 18:18:17 -0000 1.928 --- toplev.c 15 Oct 2004 14:56:50 -0000 *************** check_global_declarations (tree *vec, in *** 813,825 **** { decl = vec[i]; - if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) - && ! TREE_ASM_WRITTEN (decl)) - /* Cancel the RTL for this decl so that, if debugging info - output for global variables is still to come, - this one will be omitted. */ - SET_DECL_RTL (decl, NULL_RTX); - /* Warn about any function declared static but not defined. We don't warn about variables, --- 813,818 ----