From patchwork Sat Mar 19 00:48:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 87593 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 48C92B6F76 for ; Sat, 19 Mar 2011 11:46:28 +1100 (EST) Received: (qmail 30030 invoked by alias); 19 Mar 2011 00:46:26 -0000 Received: (qmail 29968 invoked by uid 22791); 19 Mar 2011 00:46:25 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 19 Mar 2011 00:46:19 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id D6C1A79727; Sat, 19 Mar 2011 01:46:16 +0100 (CET) Date: Sat, 19 Mar 2011 01:48:36 +0100 From: Martin Jambor To: Jan Hubicka Cc: GCC Patches Subject: Re: [PATCH, 4.7] Have all inlining destinations "analyzed" Message-ID: <20110319004836.GA32148@alvy.suse.cz> Mail-Followup-To: Jan Hubicka , GCC Patches References: <20110311095800.GA29195@virgil.arch.suse.de> <20110311143053.GC26508@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110311143053.GC26508@kam.mff.cuni.cz> User-Agent: Mutt/1.5.20 (2009-06-14) 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 Hi, On Fri, Mar 11, 2011 at 03:30:53PM +0100, Jan Hubicka wrote: > > Index: src/gcc/cgraph.c > > =================================================================== > > --- src.orig/gcc/cgraph.c > > +++ src/gcc/cgraph.c > > @@ -2495,11 +2495,11 @@ cgraph_add_new_function (tree fndecl, bo > > case CGRAPH_STATE_FINISHED: > > /* At the very end of compilation we have to do all the work up > > to expansion. */ > > + node = cgraph_node (fndecl); > > + cgraph_analyze_function (node); > > push_cfun (DECL_STRUCT_FUNCTION (fndecl)); > > current_function_decl = fndecl; > > gimple_register_cfg_hooks (); > > - if (!lowered) > > - tree_lowering_passes (fndecl); > > The analysis shoud happent in cgraph_process_new_functions that > should be called after every IPA pass. I'm not sure I understand. Since cgraph_state is in CGRAPH_STATE_FINISHED, new functions are not added to cgraph_new_nodes linked list to be picked up by cgraph_process_new_functions. If you are wondering why cgraph_state has that value because mudflap passes are early passes and so that should not happen if the function was invoked from them, the explanation is simple, it is not invoked from them. Instead this is some part of mudflap finalization invoked directly from toplev.c: #0 fancy_abort (file=0xe07230 "/home/mjambor/icln/src/gcc/tree-inline.c", line=4206, function=0xe08860 "optimize_inline_calls") at /home/mjambor/icln/src/gcc/diagnosti c.c:892 #1 0x0000000000a4ce05 in optimize_inline_calls (fn=0x7ffff5237f00) at /home/mjambor/icln/src/gcc/tree-inline.c:4206 #2 0x0000000000a1d802 in cgraph_early_inlining () at /home/mjambor/icln/src/gcc/ipa-inline.c:1757 #3 0x0000000000756ccf in execute_one_pass (pass=0x1255a00) at /home/mjambor/icln/src/gcc/passes.c:1556 #4 0x0000000000756fc5 in execute_pass_list (pass=0x1255a00) at /home/mjambor/icln/src/gcc/passes.c:1611 #5 0x0000000000a08518 in cgraph_add_new_function (fndecl=0x7ffff5237f00, lowered=0 '\000') at /home/mjambor/icln/src/gcc/cgraph.c:2505 #6 0x0000000000a342bf in cgraph_build_static_cdtor_1 (which=73 'I', body=0x7ffff53e0820, priority=, final=0 '\000') at /home/mjambor/icln/src/gcc/ipa.c:1593 #7 0x00000000004e2683 in mudflap_finish_file () at /home/mjambor/icln/src/gcc/tree-mudflap.c:1366 #8 0x00000000007fe3f9 in compile_file (argc=34, argv=0x7fffffffddf8) at /home/mjambor/icln/src/gcc/toplev.c:601 #9 do_compile (argc=34, argv=0x7fffffffddf8) at /home/mjambor/icln/src/gcc/toplev.c:1900 #10 toplev_main (argc=34, argv=0x7fffffffddf8) at /home/mjambor/icln/src/gcc/toplev.c:1963 > I don't think we should move > analysis here nor we should drop the !lowered path (even if it is > unused currently, cgraph_add_new_function is supposed to work on > unlowered functions). I'm not really dropping that path. cgraph_analyze_function calls cgraph_lower_function which calls tree_lowering_passes. It even calls lower_nested_functions and, perhaps more importantly, sets node->lowered to true. But I see that lowered is actually a function parameter that we should honor so I adjusted my patch slightly to do that. Is the explanation above enough to persuade you that the adjusted patch below is correct? (Or is there something else I still miss?) I'm about to re-bootstrap it, just to make sure it still passes. Thanks, Martin 2011-03-18 Martin Jambor * tree-inline.c (expand_call_inline): Do not check that destination node is analyzed. (optimize_inline_calls): Assert that destination node is analyzed. * cgraph.c (cgraph_add_new_function): Call cgraph_analyze_function, do not call tree_lowering_passes. * cgraph.h (cgraph_analyze_function): Declare. * cgraphunit.c (cgraph_analyze_function): Make public. Index: src/gcc/tree-inline.c =================================================================== --- src.orig/gcc/tree-inline.c 2011-03-19 01:17:10.000000000 +0100 +++ src/gcc/tree-inline.c 2011-03-19 01:31:22.000000000 +0100 @@ -3766,11 +3766,6 @@ expand_call_inline (basic_block bb, gimp if (gimple_code (stmt) != GIMPLE_CALL) goto egress; - /* Objective C and fortran still calls tree_rest_of_compilation directly. - Kill this check once this is fixed. */ - if (!id->dst_node->analyzed) - goto egress; - cg_edge = cgraph_edge (id->dst_node, stmt); gcc_checking_assert (cg_edge); /* First, see if we can figure out what function is being called. @@ -4203,6 +4198,7 @@ optimize_inline_calls (tree fn) memset (&id, 0, sizeof (id)); id.src_node = id.dst_node = cgraph_node (fn); + gcc_assert (id.dst_node->analyzed); id.dst_fn = fn; /* Or any functions that aren't finished yet. */ if (current_function_decl) Index: src/gcc/cgraph.c =================================================================== --- src.orig/gcc/cgraph.c 2011-03-19 01:17:10.000000000 +0100 +++ src/gcc/cgraph.c 2011-03-19 01:38:30.000000000 +0100 @@ -2495,11 +2495,13 @@ cgraph_add_new_function (tree fndecl, bo case CGRAPH_STATE_FINISHED: /* At the very end of compilation we have to do all the work up to expansion. */ + node = cgraph_node (fndecl); + if (lowered) + node->lowered = true; + cgraph_analyze_function (node); push_cfun (DECL_STRUCT_FUNCTION (fndecl)); current_function_decl = fndecl; gimple_register_cfg_hooks (); - if (!lowered) - tree_lowering_passes (fndecl); bitmap_obstack_initialize (NULL); if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl))) execute_pass_list (pass_early_local_passes.pass.sub); Index: src/gcc/cgraph.h =================================================================== --- src.orig/gcc/cgraph.h 2011-03-19 01:17:10.000000000 +0100 +++ src/gcc/cgraph.h 2011-03-19 01:31:22.000000000 +0100 @@ -618,6 +618,7 @@ bool varpool_used_from_object_file_p (st extern FILE *cgraph_dump_file; void cgraph_finalize_function (tree, bool); void cgraph_mark_if_needed (tree); +void cgraph_analyze_function (struct cgraph_node *); void cgraph_finalize_compilation_unit (void); void cgraph_optimize (void); void cgraph_mark_needed_node (struct cgraph_node *); Index: src/gcc/cgraphunit.c =================================================================== --- src.orig/gcc/cgraphunit.c 2011-03-19 01:17:10.000000000 +0100 +++ src/gcc/cgraphunit.c 2011-03-19 01:31:22.000000000 +0100 @@ -143,7 +143,6 @@ static void cgraph_expand_all_functions static void cgraph_mark_functions_to_output (void); static void cgraph_expand_function (struct cgraph_node *); static void cgraph_output_pending_asms (void); -static void cgraph_analyze_function (struct cgraph_node *); FILE *cgraph_dump_file; @@ -773,7 +772,7 @@ cgraph_output_pending_asms (void) } /* Analyze the function scheduled to be output. */ -static void +void cgraph_analyze_function (struct cgraph_node *node) { tree save = current_function_decl;