From patchwork Fri Mar 11 09:58:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 86391 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 7CD96B6FB3 for ; Fri, 11 Mar 2011 20:58:13 +1100 (EST) Received: (qmail 16694 invoked by alias); 11 Mar 2011 09:58:11 -0000 Received: (qmail 16685 invoked by uid 22791); 11 Mar 2011 09:58:10 -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; Fri, 11 Mar 2011 09:58:03 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 1FD4C867E2; Fri, 11 Mar 2011 10:58:01 +0100 (CET) Date: Fri, 11 Mar 2011 10:58:00 +0100 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, 4.7] Have all inlining destinations "analyzed" Message-ID: <20110311095800.GA29195@virgil.arch.suse.de> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline 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, after I simply moved id->dst_node->analyzed check from expand_call_inline to optimize_inline_calls I tried asserting it there instead. When running testsuite I found out this works for everything but mudflap which adds new nodes late with cgraph_add_new_function which runs the inliner on nodes which do not have their analyzed flag set. I believe that we can "fix" that by running cgraph_analyze_function on these new functions and test results seem to agree. Does the idea look sane? I have bootstrapped and tested the following patch on x86_64-linux on both trunk and pretty-ipa. Can I commit it now to pretty-ipa and to trunk once stage1 opens? Thanks, Martin Index: src/gcc/tree-inline.c =================================================================== --- src.orig/gcc/tree-inline.c +++ src/gcc/tree-inline.c @@ -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 +++ 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); 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 +++ src/gcc/cgraph.h @@ -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 +++ src/gcc/cgraphunit.c @@ -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;