* [PATCH 0/7] Change of call graph interface - cgraph_node function removal @ 2011-04-06 23:25 Martin Jambor 2011-04-06 23:26 ` [PATCH 3/7] cgraph_node -> cgraph_get_node with asserts Martin Jambor ` (6 more replies) 0 siblings, 7 replies; 16+ messages in thread From: Martin Jambor @ 2011-04-06 23:25 UTC (permalink / raw) To: GCC Patches; +Cc: Jan Hubicka Hi, I'm sending this email describing the set of patches also to the gcc mailing list because quite a few people do not follow the gcc-patches mailing list (where I am sending the individual patches). The patch set changes the interface of call graph and tries to avoid lazy call graph node creation wherever easily possible. Most importantly, it removes the cgraph_node function. The vast majority of call graph users should call cgraph_get_node instead. This function does not create a node when it already does not exist but returns NULL instead. Users should check for this if that can happen and might consider using gcc_checking_assert if it cannot but would result in a failure at some later point (unlike in the previous version of the patches, there is no cgraph_do_get_node doing this for you). In the very few cases where cgraph_get_node is not sufficient for you because you need to create a node, two new functions for that purpose are introduced. cgraph_create_node creates a call graph node for a declaration and aborts if it already exists. cgraph_get_create_node tries to find an existing node for a declaration and creates it if it does not already exist. Over the long term we would like to convert some more calls to cgraph_get_create_node to other accessors (ideally it should be used only in cgraphbuild.c) so please refrain from adding them unless you absolutely have to. I have successfully bootstrapped and tested the patches piecemeal on x86_64-linux with "all,ada" languages (and enabled checking), I have bootstrapped and tested the whole set with the same languages on i686, I have verified that c and c++ testsuite passes on ia64 and a similar test is in progress on sparc64. Are the patches OK for trunk? Thanks, Martin ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/7] cgraph_node -> cgraph_get_node with asserts 2011-04-06 23:25 [PATCH 0/7] Change of call graph interface - cgraph_node function removal Martin Jambor @ 2011-04-06 23:26 ` Martin Jambor 2011-04-11 10:20 ` Jan Hubicka 2011-04-06 23:26 ` [PATCH 5/7] Tweaks to C++ -> call graph interface Martin Jambor ` (5 subsequent siblings) 6 siblings, 1 reply; 16+ messages in thread From: Martin Jambor @ 2011-04-06 23:26 UTC (permalink / raw) To: GCC Patches; +Cc: Jan Hubicka [-- Attachment #1: get_cgraph_force.diff --] [-- Type: text/plain, Size: 4914 bytes --] Hi, the patch below changes a number of calls to cgraph_node to calls to cgraph_get_node. These calls should never return NULL but because the callers do not immediately dereference the pointer they get, a NULL value would result in a segmentation fault at some later point, obscuring the real cause. Therefore I have added checking asserts to guard this does not happen. Bootstrapped and tested separately on x86_64-linux without any problems, tests on other platforms (together with the other patches) in progress. OK for trunk? Thanks, Martin 2011-04-06 Martin Jambor <mjambor@suse.cz> * tree-inline.c (tree_function_versioning): Call cgraph_get_node instead of cgraph_node and assert it does not return NULL. * lto-streamer-in.c (lto_read_body): Likewise. * omp-low.c (new_omp_context): Likewise. (create_task_copyfn): Likewise. * tree-emutls.c (lower_emutls_function_body): Likewise. * matrix-reorg.c (transform_allocation_sites): Likewise. Index: src/gcc/tree-inline.c =================================================================== --- src.orig/gcc/tree-inline.c +++ src/gcc/tree-inline.c @@ -5001,8 +5001,10 @@ tree_function_versioning (tree old_decl, && TREE_CODE (new_decl) == FUNCTION_DECL); DECL_POSSIBLY_INLINED (old_decl) = 1; - old_version_node = cgraph_node (old_decl); - new_version_node = cgraph_node (new_decl); + old_version_node = cgraph_get_node (old_decl); + gcc_checking_assert (old_version_node); + new_version_node = cgraph_get_node (new_decl); + gcc_checking_assert (new_version_node); /* Output the inlining info for this abstract function, since it has been inlined. If we don't do this now, we can lose the information about the Index: src/gcc/lto-streamer-in.c =================================================================== --- src.orig/gcc/lto-streamer-in.c +++ src/gcc/lto-streamer-in.c @@ -1446,8 +1446,9 @@ lto_read_body (struct lto_file_decl_data { struct function *fn = DECL_STRUCT_FUNCTION (fn_decl); struct lto_in_decl_state *decl_state; - struct cgraph_node *node = cgraph_node (fn_decl); + struct cgraph_node *node = cgraph_get_node (fn_decl); + gcc_checking_assert (node); push_cfun (fn); init_tree_ssa (fn); Index: src/gcc/omp-low.c =================================================================== --- src.orig/gcc/omp-low.c +++ src/gcc/omp-low.c @@ -1209,7 +1209,8 @@ new_omp_context (gimple stmt, omp_contex { ctx->cb.src_fn = current_function_decl; ctx->cb.dst_fn = current_function_decl; - ctx->cb.src_node = cgraph_node (current_function_decl); + ctx->cb.src_node = cgraph_get_node (current_function_decl); + gcc_checking_assert (ctx->cb.src_node); ctx->cb.dst_node = ctx->cb.src_node; ctx->cb.src_cfun = cfun; ctx->cb.copy_decl = omp_copy_decl; @@ -6263,7 +6264,8 @@ create_task_copyfn (gimple task_stmt, om memset (&tcctx, '\0', sizeof (tcctx)); tcctx.cb.src_fn = ctx->cb.src_fn; tcctx.cb.dst_fn = child_fn; - tcctx.cb.src_node = cgraph_node (tcctx.cb.src_fn); + tcctx.cb.src_node = cgraph_get_node (tcctx.cb.src_fn); + gcc_checking_assert (tcctx.cb.src_node); tcctx.cb.dst_node = tcctx.cb.src_node; tcctx.cb.src_cfun = ctx->cb.src_cfun; tcctx.cb.copy_decl = task_copyfn_copy_decl; Index: src/gcc/tree-emutls.c =================================================================== --- src.orig/gcc/tree-emutls.c +++ src/gcc/tree-emutls.c @@ -619,7 +619,8 @@ lower_emutls_function_body (struct cgrap d.cfun_node = node; d.builtin_decl = built_in_decls[BUILT_IN_EMUTLS_GET_ADDRESS]; - d.builtin_node = cgraph_node (d.builtin_decl); + d.builtin_node = cgraph_get_node (d.builtin_decl); + gcc_checking_assert (d.builtin_node); FOR_EACH_BB (d.bb) { Index: src/gcc/matrix-reorg.c =================================================================== --- src.orig/gcc/matrix-reorg.c +++ src/gcc/matrix-reorg.c @@ -2169,7 +2169,8 @@ transform_allocation_sites (void **slot, update_ssa (TODO_update_ssa); /* Replace the malloc size argument in the malloc of level 0 to be the size of all the dimensions. */ - c_node = cgraph_node (mi->allocation_function_decl); + c_node = cgraph_get_node (mi->allocation_function_decl); + gcc_checking_assert (c_node); old_size_0 = gimple_call_arg (call_stmt_0, 0); tmp = force_gimple_operand_gsi (&gsi, mi->dimension_size[0], true, NULL, true, GSI_SAME_STMT); @@ -2218,7 +2219,8 @@ transform_allocation_sites (void **slot, if (!mi->free_stmts[i].stmt) continue; - c_node = cgraph_node (mi->free_stmts[i].func); + c_node = cgraph_get_node (mi->free_stmts[i].func); + gcc_checking_assert (c_node); gcc_assert (is_gimple_call (mi->free_stmts[i].stmt)); e = cgraph_edge (c_node, mi->free_stmts[i].stmt); gcc_assert (e); ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/7] cgraph_node -> cgraph_get_node with asserts 2011-04-06 23:26 ` [PATCH 3/7] cgraph_node -> cgraph_get_node with asserts Martin Jambor @ 2011-04-11 10:20 ` Jan Hubicka 0 siblings, 0 replies; 16+ messages in thread From: Jan Hubicka @ 2011-04-11 10:20 UTC (permalink / raw) To: Martin Jambor; +Cc: GCC Patches, Jan Hubicka > 2011-04-06 Martin Jambor <mjambor@suse.cz> > > * tree-inline.c (tree_function_versioning): Call cgraph_get_node > instead of cgraph_node and assert it does not return NULL. > * lto-streamer-in.c (lto_read_body): Likewise. > * omp-low.c (new_omp_context): Likewise. > (create_task_copyfn): Likewise. > * tree-emutls.c (lower_emutls_function_body): Likewise. > * matrix-reorg.c (transform_allocation_sites): Likewise. OK. The code in tree_function_versioning would die a little bit later, but I guess extra checking assert do no hurt. Honza ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/7] Tweaks to C++ -> call graph interface 2011-04-06 23:25 [PATCH 0/7] Change of call graph interface - cgraph_node function removal Martin Jambor 2011-04-06 23:26 ` [PATCH 3/7] cgraph_node -> cgraph_get_node with asserts Martin Jambor @ 2011-04-06 23:26 ` Martin Jambor 2011-04-11 15:30 ` Jason Merrill 2011-04-06 23:26 ` [PATCH 2/7] cgraph_node -> cgraph_get_node conversions accepting NULL results Martin Jambor ` (4 subsequent siblings) 6 siblings, 1 reply; 16+ messages in thread From: Martin Jambor @ 2011-04-06 23:26 UTC (permalink / raw) To: GCC Patches; +Cc: Jan Hubicka [-- Attachment #1: cgraph_cp_calls.diff --] [-- Type: text/plain, Size: 4637 bytes --] I concede that my understanding of the C++ front-end inner workings are quite narrow and so the folling is basically a suggestion. But it seems to me that at a few places where C++ queries the call graph for a node, the lazy node creation is not necessary. If a maintainer can verify and approve (parts of) this after the big patch is committed, it would be a nice cleanup too. Bootstrapped and tested on x86_64-linux without any problems, tests on other platforms in progress. Thanks, Martin 2011-04-06 Martin Jambor <mjambor@suse.cz> cp/ * class.c (cp_fold_obj_type_ref): Call cgraph_get_node instead of cgraph_get_create_node. * decl2.c (cp_write_global_declarations): Call cgraph_get_node instead of cgraph_get_create_node. * method.c (make_alias_for_thunk): Call cgraph_get_node instead of cgraph_get_create_node, assert it returns non-NULL. (use_thunk): Likewise. * optimize.c (maybe_clone_body): Call cgraph_same_body_alias only when flag_syntax_only is not set. Call cgraph_get_node instead of cgraph_get_create_node. (maybe_clone_body): Call cgraph_get_node instead of cgraph_get_create_node. Index: src/gcc/cp/class.c =================================================================== --- src.orig/gcc/cp/class.c +++ src/gcc/cp/class.c @@ -8401,7 +8401,7 @@ cp_fold_obj_type_ref (tree ref, tree kno DECL_VINDEX (fndecl))); #endif - cgraph_get_create_node (fndecl)->local.vtable_method = true; + cgraph_get_node (fndecl)->local.vtable_method = true; return build_address (fndecl); } Index: src/gcc/cp/decl2.c =================================================================== --- src.orig/gcc/cp/decl2.c +++ src/gcc/cp/decl2.c @@ -3893,7 +3893,7 @@ cp_write_global_declarations (void) if (!DECL_EXTERNAL (decl) && decl_needed_p (decl) && !TREE_ASM_WRITTEN (decl) - && !cgraph_get_create_node (decl)->local.finalized) + && !cgraph_get_node (decl)->local.finalized) { /* We will output the function; no longer consider it in this loop. */ Index: src/gcc/cp/method.c =================================================================== --- src.orig/gcc/cp/method.c +++ src/gcc/cp/method.c @@ -259,9 +259,10 @@ make_alias_for_thunk (tree function) if (!flag_syntax_only) { - struct cgraph_node *aliasn; - aliasn = cgraph_same_body_alias (cgraph_get_create_node (function), - alias, function); + struct cgraph_node *funcn, *aliasn; + funcn = cgraph_get_node (function); + gcc_checking_assert (funcn); + aliasn = cgraph_same_body_alias (funcn, alias, function); DECL_ASSEMBLER_NAME (function); gcc_assert (aliasn != NULL); } @@ -280,6 +281,7 @@ use_thunk (tree thunk_fndecl, bool emit_ tree virtual_offset; HOST_WIDE_INT fixed_offset, virtual_value; bool this_adjusting = DECL_THIS_THUNK_P (thunk_fndecl); + struct cgraph_node *funcn; /* We should have called finish_thunk to give it a name. */ gcc_assert (DECL_NAME (thunk_fndecl)); @@ -379,7 +381,9 @@ use_thunk (tree thunk_fndecl, bool emit_ a = nreverse (t); DECL_ARGUMENTS (thunk_fndecl) = a; TREE_ASM_WRITTEN (thunk_fndecl) = 1; - cgraph_add_thunk (cgraph_get_create_node (function), thunk_fndecl, function, + funcn = cgraph_get_node (function); + gcc_checking_assert (funcn); + cgraph_add_thunk (funcn, thunk_fndecl, function, this_adjusting, fixed_offset, virtual_value, virtual_offset, alias); Index: src/gcc/cp/optimize.c =================================================================== --- src.orig/gcc/cp/optimize.c +++ src/gcc/cp/optimize.c @@ -309,8 +309,9 @@ maybe_clone_body (tree fn) && (!DECL_ONE_ONLY (fns[0]) || (HAVE_COMDAT_GROUP && DECL_WEAK (fns[0]))) - && cgraph_same_body_alias (cgraph_get_create_node (fns[0]), clone, - fns[0])) + && (flag_syntax_only + || cgraph_same_body_alias (cgraph_get_node (fns[0]), clone, + fns[0]))) { alias = true; if (DECL_ONE_ONLY (fns[0])) @@ -424,8 +425,8 @@ maybe_clone_body (tree fn) /* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is virtual, it goes into the same comdat group as well. */ DECL_COMDAT_GROUP (fns[2]) = comdat_group; - base_dtor_node = cgraph_get_create_node (fns[0]); - deleting_dtor_node = cgraph_get_create_node (fns[2]); + base_dtor_node = cgraph_get_node (fns[0]); + deleting_dtor_node = cgraph_get_node (fns[2]); gcc_assert (base_dtor_node->same_comdat_group == NULL); gcc_assert (deleting_dtor_node->same_comdat_group == NULL); base_dtor_node->same_comdat_group = deleting_dtor_node; ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/7] Tweaks to C++ -> call graph interface 2011-04-06 23:26 ` [PATCH 5/7] Tweaks to C++ -> call graph interface Martin Jambor @ 2011-04-11 15:30 ` Jason Merrill 0 siblings, 0 replies; 16+ messages in thread From: Jason Merrill @ 2011-04-11 15:30 UTC (permalink / raw) To: Martin Jambor; +Cc: GCC Patches, Jan Hubicka OK. Jason ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/7] cgraph_node -> cgraph_get_node conversions accepting NULL results 2011-04-06 23:25 [PATCH 0/7] Change of call graph interface - cgraph_node function removal Martin Jambor 2011-04-06 23:26 ` [PATCH 3/7] cgraph_node -> cgraph_get_node with asserts Martin Jambor 2011-04-06 23:26 ` [PATCH 5/7] Tweaks to C++ -> call graph interface Martin Jambor @ 2011-04-06 23:26 ` Martin Jambor 2011-04-11 10:18 ` Jan Hubicka 2011-04-06 23:26 ` [PATCH 7/7] Tweaks to objc -> call graph interface Martin Jambor ` (3 subsequent siblings) 6 siblings, 1 reply; 16+ messages in thread From: Martin Jambor @ 2011-04-06 23:26 UTC (permalink / raw) To: GCC Patches; +Cc: Jan Hubicka [-- Attachment #1: get_cgraph_fixup.diff --] [-- Type: text/plain, Size: 8479 bytes --] Hi, this patch converts a number of calls to cgraph_node to calls to cgraph_get_node and provides means to deal with returned NULL value. These are essentially the places where lazy node creation was happening for no good reason. Bootstrapped and tested separately on x86_64-linux without any problems, tests on other platforms (together with the other patches) in progress. OK for trunk? Thanks, Martin 2011-04-06 Martin Jambor <mjambor@suse.cz> gcc/ * cgraph.c (cgraph_local_info): Call cgraph_get_node instead of cgraph_node, handle NULL return value. (cgraph_global_info): Likewise. (cgraph_rtl_info): Likewise. * tree-inline.c (estimate_num_insns): Likewise. * gimplify.c (unshare_body): Likewise. (unvisit_body): Likewise. (gimplify_body): Likewise. * predict.c (optimize_function_for_size_p): Likewise. * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Likewise. (call_may_clobber_ref_p_1): Likewise. * varasm.c (function_section_1): Likewise. (assemble_start_function): Likewise. gcc/java/ * decl.c (java_mark_decl_local): Call cgraph_get_node instead of cgraph_node and handle returned NULL. Index: src/gcc/cgraph.c =================================================================== --- src.orig/gcc/cgraph.c +++ src/gcc/cgraph.c @@ -1766,7 +1766,9 @@ cgraph_local_info (tree decl) struct cgraph_node *node; gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); - node = cgraph_node (decl); + node = cgraph_get_node (decl); + if (!node) + return NULL; return &node->local; } @@ -1778,7 +1780,9 @@ cgraph_global_info (tree decl) struct cgraph_node *node; gcc_assert (TREE_CODE (decl) == FUNCTION_DECL && cgraph_global_info_ready); - node = cgraph_node (decl); + node = cgraph_get_node (decl); + if (!node) + return NULL; return &node->global; } @@ -1790,9 +1794,10 @@ cgraph_rtl_info (tree decl) struct cgraph_node *node; gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); - node = cgraph_node (decl); - if (decl != current_function_decl - && !TREE_ASM_WRITTEN (node->decl)) + node = cgraph_get_node (decl); + if (!node + || (decl != current_function_decl + && !TREE_ASM_WRITTEN (node->decl))) return NULL; return &node->rtl; } Index: src/gcc/tree-inline.c =================================================================== --- src.orig/gcc/tree-inline.c +++ src/gcc/tree-inline.c @@ -3470,10 +3470,11 @@ estimate_num_insns (gimple stmt, eni_wei case GIMPLE_CALL: { tree decl = gimple_call_fndecl (stmt); + struct cgraph_node *node; /* Do not special case builtins where we see the body. This just confuse inliner. */ - if (!decl || cgraph_node (decl)->analyzed) + if (!decl || !(node = cgraph_get_node (decl)) || node->analyzed) ; /* For buitins that are likely expanded to nothing or inlined do not account operand costs. */ Index: src/gcc/gimplify.c =================================================================== --- src.orig/gcc/gimplify.c +++ src/gcc/gimplify.c @@ -959,11 +959,11 @@ copy_if_shared (tree *tp) static void unshare_body (tree *body_p, tree fndecl) { - struct cgraph_node *cgn = cgraph_node (fndecl); + struct cgraph_node *cgn = cgraph_get_node (fndecl); copy_if_shared (body_p); - if (body_p == &DECL_SAVED_TREE (fndecl)) + if (cgn && body_p == &DECL_SAVED_TREE (fndecl)) for (cgn = cgn->nested; cgn; cgn = cgn->next_nested) unshare_body (&DECL_SAVED_TREE (cgn->decl), cgn->decl); } @@ -1000,11 +1000,11 @@ unmark_visited (tree *tp) static void unvisit_body (tree *body_p, tree fndecl) { - struct cgraph_node *cgn = cgraph_node (fndecl); + struct cgraph_node *cgn = cgraph_get_node (fndecl); unmark_visited (body_p); - if (body_p == &DECL_SAVED_TREE (fndecl)) + if (cgn && body_p == &DECL_SAVED_TREE (fndecl)) for (cgn = cgn->nested; cgn; cgn = cgn->next_nested) unvisit_body (&DECL_SAVED_TREE (cgn->decl), cgn->decl); } @@ -7695,6 +7695,7 @@ gimplify_body (tree *body_p, tree fndecl gimple_seq parm_stmts, seq; gimple outer_bind; struct gimplify_ctx gctx; + struct cgraph_node *cgn; timevar_push (TV_TREE_GIMPLIFY); @@ -7712,7 +7713,8 @@ gimplify_body (tree *body_p, tree fndecl unshare_body (body_p, fndecl); unvisit_body (body_p, fndecl); - if (cgraph_node (fndecl)->origin) + cgn = cgraph_get_node (fndecl); + if (cgn && cgn->origin) nonlocal_vlas = pointer_set_create (); /* Make sure input_location isn't set to something weird. */ Index: src/gcc/predict.c =================================================================== --- src.orig/gcc/predict.c +++ src/gcc/predict.c @@ -214,10 +214,11 @@ probably_never_executed_bb_p (const_basi bool optimize_function_for_size_p (struct function *fun) { + struct cgraph_node *node; return (optimize_size || (fun && fun->decl - && (cgraph_node (fun->decl)->frequency - == NODE_FREQUENCY_UNLIKELY_EXECUTED))); + && (node = cgraph_get_node (fun->decl)) + && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))); } /* Return true when current function should always be optimized for speed. */ Index: src/gcc/tree-ssa-alias.c =================================================================== --- src.orig/gcc/tree-ssa-alias.c +++ src/gcc/tree-ssa-alias.c @@ -1245,14 +1245,18 @@ ref_maybe_used_by_call_p_1 (gimple call, /* Check if base is a global static variable that is not read by the function. */ - if (TREE_CODE (base) == VAR_DECL + if (callee != NULL_TREE + && TREE_CODE (base) == VAR_DECL && TREE_STATIC (base)) { + struct cgraph_node *node = cgraph_get_node (callee); bitmap not_read; - if (callee != NULL_TREE - && (not_read - = ipa_reference_get_not_read_global (cgraph_node (callee))) + /* FIXME: Callee can be an OMP builtin that does not have a call graph + node yet. We should enforce that there are nodes for all decls in the + IL and remove this check instead. */ + if (node + && (not_read = ipa_reference_get_not_read_global (node)) && bitmap_bit_p (not_read, DECL_UID (base))) goto process_args; } @@ -1512,10 +1516,11 @@ call_may_clobber_ref_p_1 (gimple call, a && TREE_CODE (base) == VAR_DECL && TREE_STATIC (base)) { + struct cgraph_node *node = cgraph_get_node (callee); bitmap not_written; - if ((not_written - = ipa_reference_get_not_written_global (cgraph_node (callee))) + if (node + && (not_written = ipa_reference_get_not_written_global (node)) && bitmap_bit_p (not_written, DECL_UID (base))) return false; } Index: src/gcc/varasm.c =================================================================== --- src.orig/gcc/varasm.c +++ src/gcc/varasm.c @@ -605,11 +605,14 @@ function_section_1 (tree decl, bool forc if (decl) { - struct cgraph_node *node = cgraph_node (decl); + struct cgraph_node *node = cgraph_get_node (decl); - freq = node->frequency; - startup = node->only_called_at_startup; - exit = node->only_called_at_exit; + if (node) + { + freq = node->frequency; + startup = node->only_called_at_startup; + exit = node->only_called_at_exit; + } } if (force_cold) freq = NODE_FREQUENCY_UNLIKELY_EXECUTED; @@ -1607,11 +1610,12 @@ assemble_start_function (tree decl, cons } else if (DECL_SECTION_NAME (decl)) { + struct cgraph_node *node = cgraph_get_node (current_function_decl); /* Calls to function_section rely on first_function_block_is_cold being accurate. */ - first_function_block_is_cold - = (cgraph_node (current_function_decl)->frequency - == NODE_FREQUENCY_UNLIKELY_EXECUTED); + first_function_block_is_cold = (node + && node->frequency + == NODE_FREQUENCY_UNLIKELY_EXECUTED); } in_cold_section_p = first_function_block_is_cold; Index: src/gcc/java/decl.c =================================================================== --- src.orig/gcc/java/decl.c +++ src/gcc/java/decl.c @@ -1928,7 +1928,10 @@ java_mark_decl_local (tree decl) #ifdef ENABLE_CHECKING /* Double check that we didn't pass the function to the callgraph early. */ if (TREE_CODE (decl) == FUNCTION_DECL) - gcc_assert (!cgraph_node (decl)->local.finalized); + { + struct cgraph_node *node = cgraph_get_node (decl); + gcc_assert (!node || !node->local.finalized); + } #endif gcc_assert (!DECL_RTL_SET_P (decl)); } ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] cgraph_node -> cgraph_get_node conversions accepting NULL results 2011-04-06 23:26 ` [PATCH 2/7] cgraph_node -> cgraph_get_node conversions accepting NULL results Martin Jambor @ 2011-04-11 10:18 ` Jan Hubicka 2011-04-11 13:33 ` Martin Jambor 0 siblings, 1 reply; 16+ messages in thread From: Jan Hubicka @ 2011-04-11 10:18 UTC (permalink / raw) To: Martin Jambor; +Cc: GCC Patches, Jan Hubicka > 2011-04-06 Martin Jambor <mjambor@suse.cz> > > gcc/ > * cgraph.c (cgraph_local_info): Call cgraph_get_node instead > of cgraph_node, handle NULL return value. > (cgraph_global_info): Likewise. > (cgraph_rtl_info): Likewise. > * tree-inline.c (estimate_num_insns): Likewise. > * gimplify.c (unshare_body): Likewise. > (unvisit_body): Likewise. > (gimplify_body): Likewise. > * predict.c (optimize_function_for_size_p): Likewise. > * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Likewise. > (call_may_clobber_ref_p_1): Likewise. > * varasm.c (function_section_1): Likewise. > (assemble_start_function): Likewise. > > gcc/java/ > * decl.c (java_mark_decl_local): Call cgraph_get_node instead of > cgraph_node and handle returned NULL. OK. > Index: src/gcc/predict.c > =================================================================== > --- src.orig/gcc/predict.c > +++ src/gcc/predict.c > @@ -214,10 +214,11 @@ probably_never_executed_bb_p (const_basi > bool > optimize_function_for_size_p (struct function *fun) > { > + struct cgraph_node *node; > return (optimize_size > || (fun && fun->decl > - && (cgraph_node (fun->decl)->frequency > - == NODE_FREQUENCY_UNLIKELY_EXECUTED))); > + && (node = cgraph_get_node (fun->decl)) > + && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))); I guess this is because optimize_function_for_size_p is used from folder that in turn is called before cgraph is built. Please, for consistency, add same test into the other predicates that calls cgraph_node (fun->decl) here and also uwind the statement into series of ifs. It has grown in to quite a beast. This is preaproved either as this patch of followup. Honza ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] cgraph_node -> cgraph_get_node conversions accepting NULL results 2011-04-11 10:18 ` Jan Hubicka @ 2011-04-11 13:33 ` Martin Jambor 0 siblings, 0 replies; 16+ messages in thread From: Martin Jambor @ 2011-04-11 13:33 UTC (permalink / raw) To: Jan Hubicka; +Cc: GCC Patches Hi, On Mon, Apr 11, 2011 at 12:18:24PM +0200, Jan Hubicka wrote: > > 2011-04-06 Martin Jambor <mjambor@suse.cz> > > > > gcc/ > > * cgraph.c (cgraph_local_info): Call cgraph_get_node instead > > of cgraph_node, handle NULL return value. > > (cgraph_global_info): Likewise. > > (cgraph_rtl_info): Likewise. > > * tree-inline.c (estimate_num_insns): Likewise. > > * gimplify.c (unshare_body): Likewise. > > (unvisit_body): Likewise. > > (gimplify_body): Likewise. > > * predict.c (optimize_function_for_size_p): Likewise. > > * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Likewise. > > (call_may_clobber_ref_p_1): Likewise. > > * varasm.c (function_section_1): Likewise. > > (assemble_start_function): Likewise. > > > > gcc/java/ > > * decl.c (java_mark_decl_local): Call cgraph_get_node instead of > > cgraph_node and handle returned NULL. > > OK. Thnanks! I'm in the process of re-bootstrapping and will start committing the patches soon. However... > > Index: src/gcc/predict.c > > =================================================================== > > --- src.orig/gcc/predict.c > > +++ src/gcc/predict.c > > @@ -214,10 +214,11 @@ probably_never_executed_bb_p (const_basi > > bool > > optimize_function_for_size_p (struct function *fun) > > { > > + struct cgraph_node *node; > > return (optimize_size > > || (fun && fun->decl > > - && (cgraph_node (fun->decl)->frequency > > - == NODE_FREQUENCY_UNLIKELY_EXECUTED))); > > + && (node = cgraph_get_node (fun->decl)) > > + && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))); > > I guess this is because optimize_function_for_size_p is used from folder > that in turn is called before cgraph is built. > Please, for consistency, add same > test into the other predicates that calls cgraph_node (fun->decl) here ...there are no such places in in predict.c, the other two calls to cgraph_(get_)node pass current_function_decl to the function. Or did you mean some other file? > and also uwind the statement into series of ifs. It has grown in to > quite a beast. This is preaproved either as this patch of followup. OK, I've turned the body of the predicate into: /* Return true when current function should always be optimized for size. */ bool optimize_function_for_size_p (struct function *fun) { struct cgraph_node *node; if (optimize_size) return true; if (!fun || !fun->decl) return false; node = cgraph_get_node (fun->decl); if (node && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)) return true; else return false; } Thanks, Martin ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 7/7] Tweaks to objc -> call graph interface 2011-04-06 23:25 [PATCH 0/7] Change of call graph interface - cgraph_node function removal Martin Jambor ` (2 preceding siblings ...) 2011-04-06 23:26 ` [PATCH 2/7] cgraph_node -> cgraph_get_node conversions accepting NULL results Martin Jambor @ 2011-04-06 23:26 ` Martin Jambor 2011-04-06 23:26 ` [PATCH 1/7] Simple cgraph_node -> cgraph_get_node conversions Martin Jambor ` (2 subsequent siblings) 6 siblings, 0 replies; 16+ messages in thread From: Martin Jambor @ 2011-04-06 23:26 UTC (permalink / raw) To: GCC Patches; +Cc: Jan Hubicka [-- Attachment #1: cgraph_objc_calls.diff --] [-- Type: text/plain, Size: 1449 bytes --] Hi, this is really only based on successful testing and not much analyzis of the context but it seems that we don't need lazy node construction here. It would be nice not to have it after the big patch gets in. Bootstrapped and tested on x86_64-linux without any problems, tests on i686 in progress. Thanks, Martin 2011-04-06 Martin Jambor <mjambor@suse.cz> * objc-act.c (mark_referenced_methods): Call cgraph_get_node instead of cgraph_get_create_node and assert it does not returns NULL. Index: src/gcc/objc/objc-act.c =================================================================== --- src.orig/gcc/objc/objc-act.c +++ src/gcc/objc/objc-act.c @@ -4519,16 +4519,20 @@ mark_referenced_methods (void) chain = CLASS_CLS_METHODS (impent->imp_context); while (chain) { - cgraph_mark_needed_node ( - cgraph_get_create_node (METHOD_DEFINITION (chain))); + struct cgraph_node *node; + node = cgraph_get_node (METHOD_DEFINITION (chain)); + gcc_checking_assert (node); + cgraph_mark_needed_node (node); chain = DECL_CHAIN (chain); } chain = CLASS_NST_METHODS (impent->imp_context); while (chain) { - cgraph_mark_needed_node ( - cgraph_get_create_node (METHOD_DEFINITION (chain))); + struct cgraph_node *node; + node = cgraph_get_node (METHOD_DEFINITION (chain)); + gcc_checking_assert (node); + cgraph_mark_needed_node (node); chain = DECL_CHAIN (chain); } } ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/7] Simple cgraph_node -> cgraph_get_node conversions 2011-04-06 23:25 [PATCH 0/7] Change of call graph interface - cgraph_node function removal Martin Jambor ` (3 preceding siblings ...) 2011-04-06 23:26 ` [PATCH 7/7] Tweaks to objc -> call graph interface Martin Jambor @ 2011-04-06 23:26 ` Martin Jambor 2011-04-11 10:13 ` Jan Hubicka 2011-04-13 13:09 ` H.J. Lu 2011-04-06 23:26 ` [PATCH 4/7] Removal of cgraph_node function Martin Jambor 2011-04-06 23:26 ` [PATCH 6/7] A tweak to fortran -> call graph interface Martin Jambor 6 siblings, 2 replies; 16+ messages in thread From: Martin Jambor @ 2011-04-06 23:26 UTC (permalink / raw) To: GCC Patches; +Cc: Jan Hubicka [-- Attachment #1: get_cgraph_direct.diff --] [-- Type: text/plain, Size: 19440 bytes --] Hi, this patch changes most of current calls to cgraph_node to calls to cgraph_get_node. The function should never return NULL in he contexts of the callers below and either the probability is so low that it does not warrant an assert (like cgraph_get_node (current_function_decl) or the result is immediately dereferenced and so would segfault anyway. Bootstrapped and tested separately on x86_64-linux without any problems, tests on other platforms (together with the other patches) in progress. OK for trunk? Thanks, Martin 2011-04-06 Martin Jambor <mjambor@suse.cz> * except.c (set_nothrow_function_flags): Call cgraph_get_node instead of cgraph_node. * final.c (rest_of_clean_state): Likewise. * gimple-iterator.c (update_call_edge_frequencies): Likewise. * passes.c (pass_init_dump_file): Likewise. (execute_all_ipa_transforms): Likewise. (function_called_by_processed_nodes_p): Likewise. * predict.c (maybe_hot_frequency_p): Likewise. (probably_never_executed_bb_p): Likewise. (compute_function_frequency): Likewise. * tree-nested.c (check_for_nested_with_variably_modified): Likewise. (unnest_nesting_tree_1): Likewise. (lower_nested_functions): Likewise. * tree-optimize.c (execute_fixup_cfg): Likewise. (tree_rest_of_compilation): Likewise. * tree-profile.c (gimple_gen_ic_func_profiler): Likewise. * tree-sra.c (ipa_early_sra): Likewise. * tree-ssa-loop-ivopts.c (computation_cost): Likewise. * config/i386/i386.c (ix86_compute_frame_layout): Likewise. * ipa.c (record_cdtor_fn): Likewise. * ipa-inline.c (cgraph_early_inlining): Likewise. (compute_inline_parameters_for_current): Likewise. * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise. * ipa-pure-const.c (local_pure_const): Likewise. * ipa-split.c (split_function): Likewise. (execute_split_functions): Likewise. * cgraphbuild.c (build_cgraph_edges): Likewise. (rebuild_cgraph_edges): Likewise. (cgraph_rebuild_references): Likewise. (remove_cgraph_callee_edges): Likewise. * cgraphunit.c (cgraph_mark_if_needed): Likewise. (verify_cgraph_node): Likewise. (cgraph_analyze_functions): Likewise. (cgraph_preserve_function_body_p): Likewise. (save_inline_function_body): Likewise. (save_inline_function_body): Likewise. * tree-inline.c (copy_bb): Likewise. (optimize_inline_calls): Likewise. Index: src/gcc/except.c =================================================================== --- src.orig/gcc/except.c +++ src/gcc/except.c @@ -1879,11 +1879,11 @@ set_nothrow_function_flags (void) } } if (crtl->nothrow - && (cgraph_function_body_availability (cgraph_node + && (cgraph_function_body_availability (cgraph_get_node (current_function_decl)) >= AVAIL_AVAILABLE)) { - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); struct cgraph_edge *e; for (e = node->callers; e; e = e->next_caller) e->can_throw_external = false; Index: src/gcc/final.c =================================================================== --- src.orig/gcc/final.c +++ src/gcc/final.c @@ -4283,7 +4283,7 @@ rest_of_clean_state (void) else { const char *aname; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); aname = (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl))); Index: src/gcc/gimple-iterator.c =================================================================== --- src.orig/gcc/gimple-iterator.c +++ src/gcc/gimple-iterator.c @@ -84,7 +84,7 @@ update_call_edge_frequencies (gimple_seq to avoid calling them if we never see any calls. */ if (cfun_node == NULL) { - cfun_node = cgraph_node (current_function_decl); + cfun_node = cgraph_get_node (current_function_decl); bb_freq = (compute_call_stmt_bb_frequency (current_function_decl, bb)); } Index: src/gcc/passes.c =================================================================== --- src.orig/gcc/passes.c +++ src/gcc/passes.c @@ -1343,7 +1343,7 @@ pass_init_dump_file (struct opt_pass *pa if (dump_file && current_function_decl) { const char *dname, *aname; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); dname = lang_hooks.decl_printable_name (current_function_decl, 2); aname = (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl))); @@ -1475,7 +1475,7 @@ execute_all_ipa_transforms (void) struct cgraph_node *node; if (!cfun) return; - node = cgraph_node (current_function_decl); + node = cgraph_get_node (current_function_decl); if (node->ipa_transforms_to_apply) { @@ -2029,7 +2029,9 @@ bool function_called_by_processed_nodes_p (void) { struct cgraph_edge *e; - for (e = cgraph_node (current_function_decl)->callers; e; e = e->next_caller) + for (e = cgraph_get_node (current_function_decl)->callers; + e; + e = e->next_caller) { if (e->caller->decl == current_function_decl) continue; Index: src/gcc/predict.c =================================================================== --- src.orig/gcc/predict.c +++ src/gcc/predict.c @@ -113,7 +113,7 @@ static const struct predictor_info predi static inline bool maybe_hot_frequency_p (int freq) { - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); if (!profile_info || !flag_branch_probabilities) { if (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED) @@ -203,7 +203,8 @@ probably_never_executed_bb_p (const_basi if (profile_info && flag_branch_probabilities) return ((bb->count + profile_info->runs / 2) / profile_info->runs) == 0; if ((!profile_info || !flag_branch_probabilities) - && cgraph_node (current_function_decl)->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED) + && (cgraph_get_node (current_function_decl)->frequency + == NODE_FREQUENCY_UNLIKELY_EXECUTED)) return true; return false; } @@ -2225,7 +2226,7 @@ void compute_function_frequency (void) { basic_block bb; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); if (DECL_STATIC_CONSTRUCTOR (current_function_decl) || MAIN_NAME_P (DECL_NAME (current_function_decl))) node->only_called_at_startup = true; Index: src/gcc/tree-nested.c =================================================================== --- src.orig/gcc/tree-nested.c +++ src/gcc/tree-nested.c @@ -693,7 +693,7 @@ walk_all_functions (walk_stmt_fn callbac static bool check_for_nested_with_variably_modified (tree fndecl, tree orig_fndecl) { - struct cgraph_node *cgn = cgraph_node (fndecl); + struct cgraph_node *cgn = cgraph_get_node (fndecl); tree arg; for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested) @@ -2523,13 +2523,13 @@ finalize_nesting_tree (struct nesting_in static void unnest_nesting_tree_1 (struct nesting_info *root) { - struct cgraph_node *node = cgraph_node (root->context); + struct cgraph_node *node = cgraph_get_node (root->context); /* For nested functions update the cgraph to reflect unnesting. We also delay finalizing of these functions up to this point. */ if (node->origin) { - cgraph_unnest_node (cgraph_node (root->context)); + cgraph_unnest_node (node); cgraph_finalize_function (root->context, true); } } @@ -2583,7 +2583,7 @@ lower_nested_functions (tree fndecl) struct nesting_info *root; /* If there are no nested functions, there's nothing to do. */ - cgn = cgraph_node (fndecl); + cgn = cgraph_get_node (fndecl); if (!cgn->nested) return; Index: src/gcc/tree-optimize.c =================================================================== --- src.orig/gcc/tree-optimize.c +++ src/gcc/tree-optimize.c @@ -247,12 +247,13 @@ execute_fixup_cfg (void) edge_iterator ei; if (ENTRY_BLOCK_PTR->count) - count_scale = (cgraph_node (current_function_decl)->count * REG_BR_PROB_BASE - + ENTRY_BLOCK_PTR->count / 2) / ENTRY_BLOCK_PTR->count; + count_scale = ((cgraph_get_node (current_function_decl)->count + * REG_BR_PROB_BASE + ENTRY_BLOCK_PTR->count / 2) + / ENTRY_BLOCK_PTR->count); else count_scale = REG_BR_PROB_BASE; - ENTRY_BLOCK_PTR->count = cgraph_node (current_function_decl)->count; + ENTRY_BLOCK_PTR->count = cgraph_get_node (current_function_decl)->count; EXIT_BLOCK_PTR->count = (EXIT_BLOCK_PTR->count * count_scale + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE; @@ -457,7 +458,7 @@ tree_rest_of_compilation (tree fndecl) gimple_set_body (fndecl, NULL); if (DECL_STRUCT_FUNCTION (fndecl) == 0 - && !cgraph_node (fndecl)->origin) + && !cgraph_get_node (fndecl)->origin) { /* Stop pointing to the local nodes about to be freed. But DECL_INITIAL must remain nonzero so we know this Index: src/gcc/tree-profile.c =================================================================== --- src.orig/gcc/tree-profile.c +++ src/gcc/tree-profile.c @@ -346,7 +346,7 @@ gimple_gen_ic_profiler (histogram_value void gimple_gen_ic_func_profiler (void) { - struct cgraph_node * c_node = cgraph_node (current_function_decl); + struct cgraph_node * c_node = cgraph_get_node (current_function_decl); gimple_stmt_iterator gsi; gimple stmt1, stmt2; tree tree_uid, cur_func, counter_ptr, ptr_var, void0; Index: src/gcc/tree-sra.c =================================================================== --- src.orig/gcc/tree-sra.c +++ src/gcc/tree-sra.c @@ -4502,7 +4502,7 @@ ipa_sra_preliminary_function_checks (str static unsigned int ipa_early_sra (void) { - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); ipa_parm_adjustment_vec adjustments; int ret = 0; Index: src/gcc/tree-ssa-loop-ivopts.c =================================================================== --- src.orig/gcc/tree-ssa-loop-ivopts.c +++ src/gcc/tree-ssa-loop-ivopts.c @@ -2849,7 +2849,7 @@ computation_cost (tree expr, bool speed) unsigned cost; /* Avoid using hard regs in ways which may be unsupported. */ int regno = LAST_VIRTUAL_REGISTER + 1; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); enum node_frequency real_frequency = node->frequency; node->frequency = NODE_FREQUENCY_NORMAL; Index: src/gcc/config/i386/i386.c =================================================================== --- src.orig/gcc/config/i386/i386.c +++ src/gcc/config/i386/i386.c @@ -9298,7 +9298,7 @@ ix86_compute_frame_layout (struct ix86_f && cfun->machine->use_fast_prologue_epilogue_nregs != frame->nregs) { int count = frame->nregs; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); cfun->machine->use_fast_prologue_epilogue_nregs = count; Index: src/gcc/ipa.c =================================================================== --- src.orig/gcc/ipa.c +++ src/gcc/ipa.c @@ -1626,7 +1626,7 @@ record_cdtor_fn (struct cgraph_node *nod VEC_safe_push (tree, heap, static_ctors, node->decl); if (DECL_STATIC_DESTRUCTOR (node->decl)) VEC_safe_push (tree, heap, static_dtors, node->decl); - node = cgraph_node (node->decl); + node = cgraph_get_node (node->decl); node->local.disregard_inline_limits = 1; } Index: src/gcc/ipa-inline.c =================================================================== --- src.orig/gcc/ipa-inline.c +++ src/gcc/ipa-inline.c @@ -1718,7 +1718,7 @@ static GTY ((length ("nnodes"))) struct static unsigned int cgraph_early_inlining (void) { - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); unsigned int todo = 0; int iterations = 0; bool inlined = false; @@ -1996,7 +1996,7 @@ compute_inline_parameters (struct cgraph static unsigned int compute_inline_parameters_for_current (void) { - compute_inline_parameters (cgraph_node (current_function_decl)); + compute_inline_parameters (cgraph_get_node (current_function_decl)); return 0; } Index: src/gcc/ipa-prop.c =================================================================== --- src.orig/gcc/ipa-prop.c +++ src/gcc/ipa-prop.c @@ -1648,7 +1648,7 @@ ipa_make_edge_direct_to_target (struct c target = TREE_OPERAND (target, 0); if (TREE_CODE (target) != FUNCTION_DECL) return NULL; - callee = cgraph_node (target); + callee = cgraph_get_node (target); if (!callee) return NULL; ipa_check_create_node_params (); Index: src/gcc/ipa-pure-const.c =================================================================== --- src.orig/gcc/ipa-pure-const.c +++ src/gcc/ipa-pure-const.c @@ -1563,7 +1563,7 @@ local_pure_const (void) bool skip; struct cgraph_node *node; - node = cgraph_node (current_function_decl); + node = cgraph_get_node (current_function_decl); skip = skip_function_for_local_pure_const (node); if (!warn_suggest_attribute_const && !warn_suggest_attribute_pure Index: src/gcc/ipa-split.c =================================================================== --- src.orig/gcc/ipa-split.c +++ src/gcc/ipa-split.c @@ -1080,7 +1080,7 @@ split_function (struct split_point *spli /* Now create the actual clone. */ rebuild_cgraph_edges (); - node = cgraph_function_versioning (cgraph_node (current_function_decl), + node = cgraph_function_versioning (cgraph_get_node (current_function_decl), NULL, NULL, args_to_skip, split_point->split_bbs, @@ -1093,7 +1093,7 @@ split_function (struct split_point *spli DECL_BUILT_IN_CLASS (node->decl) = NOT_BUILT_IN; DECL_FUNCTION_CODE (node->decl) = (enum built_in_function) 0; } - cgraph_node_remove_callees (cgraph_node (current_function_decl)); + cgraph_node_remove_callees (cgraph_get_node (current_function_decl)); if (!split_part_return_p) TREE_THIS_VOLATILE (node->decl) = 1; if (dump_file) @@ -1265,7 +1265,7 @@ execute_split_functions (void) basic_block bb; int overall_time = 0, overall_size = 0; int todo = 0; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); if (flags_from_decl_or_type (current_function_decl) & ECF_NORETURN) { Index: src/gcc/cgraphbuild.c =================================================================== --- src.orig/gcc/cgraphbuild.c +++ src/gcc/cgraphbuild.c @@ -340,7 +340,7 @@ static unsigned int build_cgraph_edges (void) { basic_block bb; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); struct pointer_set_t *visited_nodes = pointer_set_create (); gimple_stmt_iterator gsi; tree decl; @@ -451,7 +451,7 @@ unsigned int rebuild_cgraph_edges (void) { basic_block bb; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); gimple_stmt_iterator gsi; cgraph_node_remove_callees (node); @@ -502,7 +502,7 @@ void cgraph_rebuild_references (void) { basic_block bb; - struct cgraph_node *node = cgraph_node (current_function_decl); + struct cgraph_node *node = cgraph_get_node (current_function_decl); gimple_stmt_iterator gsi; ipa_remove_all_references (&node->ref_list); @@ -549,7 +549,7 @@ struct gimple_opt_pass pass_rebuild_cgra static unsigned int remove_cgraph_callee_edges (void) { - cgraph_node_remove_callees (cgraph_node (current_function_decl)); + cgraph_node_remove_callees (cgraph_get_node (current_function_decl)); return 0; } Index: src/gcc/cgraphunit.c =================================================================== --- src.orig/gcc/cgraphunit.c +++ src/gcc/cgraphunit.c @@ -390,7 +390,7 @@ cgraph_finalize_function (tree decl, boo void cgraph_mark_if_needed (tree decl) { - struct cgraph_node *node = cgraph_node (decl); + struct cgraph_node *node = cgraph_get_node (decl); if (node->local.finalized && cgraph_decide_is_function_needed (node, decl)) cgraph_mark_needed_node (node); } @@ -667,7 +667,7 @@ verify_cgraph_node (struct cgraph_node * && cgraph_get_node (decl) && (e->callee->former_clone_of != cgraph_get_node (decl)->decl) - && !clone_of_p (cgraph_node (decl), + && !clone_of_p (cgraph_get_node (decl), e->callee)) { error ("edge points to wrong declaration:"); @@ -995,10 +995,12 @@ cgraph_analyze_functions (void) /* If decl is a clone of an abstract function, mark that abstract function so that we don't release its body. The DECL_INITIAL() of that - abstract function declaration will be later needed to output debug info. */ + abstract function declaration will be later needed to output debug + info. */ if (DECL_ABSTRACT_ORIGIN (decl)) { - struct cgraph_node *origin_node = cgraph_node (DECL_ABSTRACT_ORIGIN (decl)); + struct cgraph_node *origin_node; + origin_node = cgraph_get_node (DECL_ABSTRACT_ORIGIN (decl)); origin_node->abstract_and_needed = true; } @@ -1766,7 +1768,7 @@ cgraph_preserve_function_body_p (tree de gcc_assert (cgraph_global_info_ready); /* Look if there is any clone around. */ - node = cgraph_node (decl); + node = cgraph_get_node (decl); if (node->clones) return true; return false; @@ -2106,7 +2108,7 @@ save_inline_function_body (struct cgraph { struct cgraph_node *first_clone, *n; - gcc_assert (node == cgraph_node (node->decl)); + gcc_assert (node == cgraph_get_node (node->decl)); cgraph_lower_function (node); @@ -2114,7 +2116,7 @@ save_inline_function_body (struct cgraph first_clone->decl = copy_node (node->decl); cgraph_insert_node_to_hashtable (first_clone); - gcc_assert (first_clone == cgraph_node (first_clone->decl)); + gcc_assert (first_clone == cgraph_get_node (first_clone->decl)); if (first_clone->next_sibling_clone) { for (n = first_clone->next_sibling_clone; n->next_sibling_clone; n = n->next_sibling_clone) Index: src/gcc/tree-inline.c =================================================================== --- src.orig/gcc/tree-inline.c +++ src/gcc/tree-inline.c @@ -1727,7 +1727,7 @@ copy_bb (copy_body_data *id, basic_block && id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)) && (fn = gimple_call_fndecl (stmt)) != NULL) { - struct cgraph_node *dest = cgraph_node (fn); + struct cgraph_node *dest = cgraph_get_node (fn); /* We have missing edge in the callgraph. This can happen when previous inlining turned an indirect call into a @@ -4158,7 +4158,7 @@ optimize_inline_calls (tree fn) /* Clear out ID. */ memset (&id, 0, sizeof (id)); - id.src_node = id.dst_node = cgraph_node (fn); + id.src_node = id.dst_node = cgraph_get_node (fn); gcc_assert (id.dst_node->analyzed); id.dst_fn = fn; /* Or any functions that aren't finished yet. */ ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] Simple cgraph_node -> cgraph_get_node conversions 2011-04-06 23:26 ` [PATCH 1/7] Simple cgraph_node -> cgraph_get_node conversions Martin Jambor @ 2011-04-11 10:13 ` Jan Hubicka 2011-04-13 13:09 ` H.J. Lu 1 sibling, 0 replies; 16+ messages in thread From: Jan Hubicka @ 2011-04-11 10:13 UTC (permalink / raw) To: Martin Jambor; +Cc: GCC Patches, Jan Hubicka > (compute_function_frequency): Likewise. > * tree-nested.c (check_for_nested_with_variably_modified): Likewise. > (unnest_nesting_tree_1): Likewise. > (lower_nested_functions): Likewise. > * tree-optimize.c (execute_fixup_cfg): Likewise. > (tree_rest_of_compilation): Likewise. > * tree-profile.c (gimple_gen_ic_func_profiler): Likewise. > * tree-sra.c (ipa_early_sra): Likewise. > * tree-ssa-loop-ivopts.c (computation_cost): Likewise. > * config/i386/i386.c (ix86_compute_frame_layout): Likewise. > * ipa.c (record_cdtor_fn): Likewise. > * ipa-inline.c (cgraph_early_inlining): Likewise. > (compute_inline_parameters_for_current): Likewise. > * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise. > * ipa-pure-const.c (local_pure_const): Likewise. > * ipa-split.c (split_function): Likewise. > (execute_split_functions): Likewise. > * cgraphbuild.c (build_cgraph_edges): Likewise. > (rebuild_cgraph_edges): Likewise. > (cgraph_rebuild_references): Likewise. > (remove_cgraph_callee_edges): Likewise. > * cgraphunit.c (cgraph_mark_if_needed): Likewise. > (verify_cgraph_node): Likewise. > (cgraph_analyze_functions): Likewise. > (cgraph_preserve_function_body_p): Likewise. > (save_inline_function_body): Likewise. > (save_inline_function_body): Likewise. > * tree-inline.c (copy_bb): Likewise. > (optimize_inline_calls): Likewise. > OK. Honza ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] Simple cgraph_node -> cgraph_get_node conversions 2011-04-06 23:26 ` [PATCH 1/7] Simple cgraph_node -> cgraph_get_node conversions Martin Jambor 2011-04-11 10:13 ` Jan Hubicka @ 2011-04-13 13:09 ` H.J. Lu 1 sibling, 0 replies; 16+ messages in thread From: H.J. Lu @ 2011-04-13 13:09 UTC (permalink / raw) To: Martin Jambor; +Cc: GCC Patches, Jan Hubicka On Wed, Apr 6, 2011 at 4:22 PM, Martin Jambor <mjambor@suse.cz> wrote: > Hi, > > this patch changes most of current calls to cgraph_node to calls to > cgraph_get_node. The function should never return NULL in he contexts > of the callers below and either the probability is so low that it does > not warrant an assert (like cgraph_get_node (current_function_decl) or > the result is immediately dereferenced and so would segfault anyway. > > Bootstrapped and tested separately on x86_64-linux without any > problems, tests on other platforms (together with the other patches) > in progress. > > OK for trunk? > > Thanks, > > Martin > > > 2011-04-06 Martin Jambor <mjambor@suse.cz> > > * except.c (set_nothrow_function_flags): Call cgraph_get_node instead > of cgraph_node. > * final.c (rest_of_clean_state): Likewise. > * gimple-iterator.c (update_call_edge_frequencies): Likewise. > * passes.c (pass_init_dump_file): Likewise. > (execute_all_ipa_transforms): Likewise. > (function_called_by_processed_nodes_p): Likewise. > * predict.c (maybe_hot_frequency_p): Likewise. > (probably_never_executed_bb_p): Likewise. > (compute_function_frequency): Likewise. > * tree-nested.c (check_for_nested_with_variably_modified): Likewise. > (unnest_nesting_tree_1): Likewise. > (lower_nested_functions): Likewise. > * tree-optimize.c (execute_fixup_cfg): Likewise. > (tree_rest_of_compilation): Likewise. > * tree-profile.c (gimple_gen_ic_func_profiler): Likewise. > * tree-sra.c (ipa_early_sra): Likewise. > * tree-ssa-loop-ivopts.c (computation_cost): Likewise. > * config/i386/i386.c (ix86_compute_frame_layout): Likewise. > * ipa.c (record_cdtor_fn): Likewise. > * ipa-inline.c (cgraph_early_inlining): Likewise. > (compute_inline_parameters_for_current): Likewise. > * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise. > * ipa-pure-const.c (local_pure_const): Likewise. > * ipa-split.c (split_function): Likewise. > (execute_split_functions): Likewise. > * cgraphbuild.c (build_cgraph_edges): Likewise. > (rebuild_cgraph_edges): Likewise. > (cgraph_rebuild_references): Likewise. > (remove_cgraph_callee_edges): Likewise. > * cgraphunit.c (cgraph_mark_if_needed): Likewise. > (verify_cgraph_node): Likewise. > (cgraph_analyze_functions): Likewise. > (cgraph_preserve_function_body_p): Likewise. > (save_inline_function_body): Likewise. > (save_inline_function_body): Likewise. > * tree-inline.c (copy_bb): Likewise. > (optimize_inline_calls): Likewise. > > > This patch caused: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48585 -- H.J. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/7] Removal of cgraph_node function 2011-04-06 23:25 [PATCH 0/7] Change of call graph interface - cgraph_node function removal Martin Jambor ` (4 preceding siblings ...) 2011-04-06 23:26 ` [PATCH 1/7] Simple cgraph_node -> cgraph_get_node conversions Martin Jambor @ 2011-04-06 23:26 ` Martin Jambor 2011-04-11 10:28 ` Jan Hubicka 2011-04-06 23:26 ` [PATCH 6/7] A tweak to fortran -> call graph interface Martin Jambor 6 siblings, 1 reply; 16+ messages in thread From: Martin Jambor @ 2011-04-06 23:26 UTC (permalink / raw) To: GCC Patches; +Cc: Jan Hubicka [-- Attachment #1: no_cgraph_node.diff --] [-- Type: text/plain, Size: 24686 bytes --] This patch contains the rest of the changes required to remove cgraph_node function. First, new functions cgraph_create_node and cgraph_get_create_node are introduced. The former creates a new node for decl (and aborts compilation if th node already exists) and the latter creates it if it does not exist. Second, the rest of the callers of cgraph_node outside the cgraph machinery itself are converted to one or the other, depending on whether it is safe to assume the node does not already exist. Third, the cgraph machinery itself (cgraph.c, cgraphbuild.c and cgraphunit.c) is updated not to call cgraph_node anywhere. And last but not least, cgraph_node is finally removed. To ease the approval process, this patch always converts front-end calls to cgraph_node to cgraph_get_create_node which is semantically equivalent. Subsequent patches try to relax this where possible. Bootstrapped and tested separately on x86_64-linux without any problems, tests on other platforms (together with the other patches) in progress. OK for trunk? Thanks, Martin 2011-04-06 Martin Jambor <mjambor@suse.cz> * cgraph.h (cgraph_node): Remove function declaration. (cgraph_create_node): Declare. (cgraph_get_create_node): Likewise. * cgraph.c (cgraph_create_node): Renamed to cgraph_create_node_1. Updated all callers. (cgraph_node): Renamed to cgraph_create_node, assert that a node for the decl does not already exist. Call cgraph_get_create_node instead of cgraph_node. (cgraph_get_create_node): New function. (cgraph_same_body_alias): Update comment. (cgraph_set_call_stmt): Call cgraph_get_node instead of cgraph_node, assert it does not return NULL. (cgraph_update_edges_for_call_stmt): Likewise. (cgraph_clone_edge): Likewise. (cgraph_create_virtual_clone): Likewise. (cgraph_update_edges_for_call_stmt_node): Call cgraph_get_create_node instead of cgraph_node. (cgraph_add_new_function): Call cgraph_create_node or cgraph_get_create_node instead of cgraph_node. * cgraphbuild.c (record_reference): Call cgraph_get_create_node instead of cgraph_node. (record_eh_tables): Likewise. (mark_address): Likewise. (mark_load): Likewise. (build_cgraph_edges): Call cgraph_get_create_node instead of cgraph_node. (rebuild_cgraph_edges): Likewise. * cgraphunit.c (cgraph_finalize_function): Call cgraph_get_create_node instead of cgraph_node. (cgraph_copy_node_for_versioning): Call cgraph_create_node instead of cgraph_node. * lto-symtab.c (lto_symtab_merge_cgraph_nodes_1): Call cgraph_create_node instead of cgraph_node. * c-decl.c (finish_function): Call cgraph_get_create_node instead of cgraph_node. * lto-cgraph.c (input_node): Likewise. * lto-streamer-in.c (input_function): Likewise. * varasm.c (mark_decl_referenced): Likewise. (assemble_alias): Likewise. gcc/c-family/ * c-gimplify.c (c_genericize): Call cgraph_get_create_node instead of cgraph_node. gcc/cp/ * cp/class.c (cp_fold_obj_type_ref): Call cgraph_get_create_node instead of cgraph_node. * cp/decl2.c (cxx_callgraph_analyze_expr): Likewise. (cp_write_global_declarations): Likewise. * cp/optimize.c (maybe_clone_body): Likewise. * cp/semantics.c (maybe_add_lambda_conv_op): Likewise. * cp/mangle.c (mangle_decl): Likewise. * cp/method.c (make_alias_for_thunk): Likewise. (use_thunk): Likewise. gcc/ada/ * gcc-interface/utils.c (end_subprog_body): Call cgraph_get_create_node instead of cgraph_node. gcc/fortran/ * trans-decl.c (gfc_generate_function_code): Call cgraph_get_create_node instead of cgraph_node. gcc/objc/ * objc-act.c (mark_referenced_methods): Call cgraph_get_create_node instead of cgraph_node. Index: src/gcc/c-decl.c =================================================================== --- src.orig/gcc/c-decl.c +++ src/gcc/c-decl.c @@ -8345,7 +8345,7 @@ finish_function (void) /* Register this function with cgraph just far enough to get it added to our parent's nested function list. Handy, since the C front end doesn't have such a list. */ - (void) cgraph_node (fndecl); + (void) cgraph_get_create_node (fndecl); } } Index: src/gcc/c-family/c-gimplify.c =================================================================== --- src.orig/gcc/c-family/c-gimplify.c +++ src/gcc/c-family/c-gimplify.c @@ -98,7 +98,7 @@ c_genericize (tree fndecl) } /* Dump all nested functions now. */ - cgn = cgraph_node (fndecl); + cgn = cgraph_get_create_node (fndecl); for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested) c_genericize (cgn->decl); } Index: src/gcc/cgraph.c =================================================================== --- src.orig/gcc/cgraph.c +++ src/gcc/cgraph.c @@ -466,7 +466,7 @@ cgraph_allocate_node (void) /* Allocate new callgraph node and insert it into basic data structures. */ static struct cgraph_node * -cgraph_create_node (void) +cgraph_create_node_1 (void) { struct cgraph_node *node = cgraph_allocate_node (); @@ -488,7 +488,7 @@ cgraph_create_node (void) /* Return cgraph node assigned to DECL. Create new one when needed. */ struct cgraph_node * -cgraph_node (tree decl) +cgraph_create_node (tree decl) { struct cgraph_node key, *node, **slot; @@ -498,23 +498,15 @@ cgraph_node (tree decl) cgraph_hash = htab_create_ggc (10, hash_node, eq_node, NULL); key.decl = decl; - slot = (struct cgraph_node **) htab_find_slot (cgraph_hash, &key, INSERT); + gcc_assert (!*slot); - if (*slot) - { - node = *slot; - if (node->same_body_alias) - node = node->same_body; - return node; - } - - node = cgraph_create_node (); + node = cgraph_create_node_1 (); node->decl = decl; *slot = node; if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL) { - node->origin = cgraph_node (DECL_CONTEXT (decl)); + node->origin = cgraph_get_create_node (DECL_CONTEXT (decl)); node->next_nested = node->origin->nested; node->origin->nested = node; } @@ -536,6 +528,21 @@ cgraph_node (tree decl) return node; } +/* Try to find a call graph node for declaration DECL and if it does not exist, + create it. */ + +struct cgraph_node * +cgraph_get_create_node (tree decl) +{ + struct cgraph_node *node; + + node = cgraph_get_node (decl); + if (node) + return node; + + return cgraph_create_node (decl); +} + /* Mark ALIAS as an alias to DECL. DECL_NODE is cgraph node representing the function body is associated with (not neccesarily cgraph_node (DECL). */ @@ -570,9 +577,9 @@ cgraph_same_body_alias_1 (struct cgraph_ } /* Attempt to mark ALIAS as an alias to DECL. Return alias node if successful - and NULL otherwise. + and NULL otherwise. Same body aliases are output whenever the body of DECL is output, - and cgraph_node (ALIAS) transparently returns cgraph_node (DECL). */ + and cgraph_get_node (ALIAS) transparently returns cgraph_get_node (DECL). */ struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *decl_node, tree alias, tree decl) @@ -859,8 +866,9 @@ cgraph_set_call_stmt (struct cgraph_edge { /* Constant propagation (and possibly also inlining?) can turn an indirect call into a direct one. */ - struct cgraph_node *new_callee = cgraph_node (decl); + struct cgraph_node *new_callee = cgraph_get_node (decl); + gcc_checking_assert (new_callee); cgraph_make_edge_direct (e, new_callee, 0); } @@ -1301,7 +1309,7 @@ cgraph_update_edges_for_call_stmt_node ( if (new_call) { - ne = cgraph_create_edge (node, cgraph_node (new_call), + ne = cgraph_create_edge (node, cgraph_get_create_node (new_call), new_stmt, count, frequency, loop_nest); gcc_assert (ne->inline_failed); @@ -1319,9 +1327,10 @@ cgraph_update_edges_for_call_stmt_node ( void cgraph_update_edges_for_call_stmt (gimple old_stmt, tree old_decl, gimple new_stmt) { - struct cgraph_node *orig = cgraph_node (cfun->decl); + struct cgraph_node *orig = cgraph_get_node (cfun->decl); struct cgraph_node *node; + gcc_checking_assert (orig); cgraph_update_edges_for_call_stmt_node (orig, old_stmt, old_decl, new_stmt); if (orig->clones) for (node = orig->clones; node != orig;) @@ -2123,7 +2132,8 @@ cgraph_clone_edge (struct cgraph_edge *e if (call_stmt && (decl = gimple_call_fndecl (call_stmt))) { - struct cgraph_node *callee = cgraph_node (decl); + struct cgraph_node *callee = cgraph_get_node (decl); + gcc_checking_assert (callee); new_edge = cgraph_create_edge (n, callee, call_stmt, count, freq, e->loop_nest + loop_nest); } @@ -2179,7 +2189,7 @@ cgraph_clone_node (struct cgraph_node *n int loop_nest, bool update_original, VEC(cgraph_edge_p,heap) *redirect_callers) { - struct cgraph_node *new_node = cgraph_create_node (); + struct cgraph_node *new_node = cgraph_create_node_1 (); struct cgraph_edge *e; gcov_type count_scale; unsigned i; @@ -2355,8 +2365,12 @@ cgraph_create_virtual_clone (struct cgra /* Record references of the future statement initializing the constant argument. */ if (TREE_CODE (var) == FUNCTION_DECL) - ipa_record_reference (new_node, NULL, cgraph_node (var), - NULL, IPA_REF_ADDR, NULL); + { + struct cgraph_node *ref_node = cgraph_get_node (var); + gcc_checking_assert (ref_node); + ipa_record_reference (new_node, NULL, ref_node, NULL, IPA_REF_ADDR, + NULL); + } else if (TREE_CODE (var) == VAR_DECL) ipa_record_reference (new_node, NULL, NULL, varpool_node (var), IPA_REF_ADDR, NULL); @@ -2464,7 +2478,7 @@ cgraph_add_new_function (tree fndecl, bo { case CGRAPH_STATE_CONSTRUCTION: /* Just enqueue function to be processed at nearest occurrence. */ - node = cgraph_node (fndecl); + node = cgraph_create_node (fndecl); node->next_needed = cgraph_new_nodes; if (lowered) node->lowered = true; @@ -2476,7 +2490,7 @@ cgraph_add_new_function (tree fndecl, bo case CGRAPH_STATE_EXPANSION: /* Bring the function into finalized state and enqueue for later analyzing and compilation. */ - node = cgraph_node (fndecl); + node = cgraph_get_create_node (fndecl); node->local.local = false; node->local.finalized = true; node->reachable = node->needed = true; @@ -2504,7 +2518,7 @@ 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); + node = cgraph_create_node (fndecl); if (lowered) node->lowered = true; cgraph_analyze_function (node); Index: src/gcc/cgraph.h =================================================================== --- src.orig/gcc/cgraph.h +++ src/gcc/cgraph.h @@ -561,7 +561,8 @@ struct cgraph_edge *cgraph_create_indire struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void); struct cgraph_node * cgraph_get_node (const_tree); struct cgraph_node * cgraph_get_node_or_alias (const_tree); -struct cgraph_node * cgraph_node (tree); +struct cgraph_node * cgraph_create_node (tree); +struct cgraph_node * cgraph_get_create_node (tree); struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree); struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree); Index: src/gcc/lto-cgraph.c =================================================================== --- src.orig/gcc/lto-cgraph.c +++ src/gcc/lto-cgraph.c @@ -1045,7 +1045,7 @@ input_node (struct lto_file_decl_data *f 0, CGRAPH_FREQ_BASE, 0, false, NULL); } else - node = cgraph_node (fn_decl); + node = cgraph_get_create_node (fn_decl); node->count = lto_input_sleb128 (ib); node->count_materialization_scale = lto_input_sleb128 (ib); Index: src/gcc/lto-streamer-in.c =================================================================== --- src.orig/gcc/lto-streamer-in.c +++ src/gcc/lto-streamer-in.c @@ -1301,7 +1301,7 @@ input_function (tree fn_decl, struct dat DECL_INITIAL (fn_decl) = lto_input_tree (ib, data_in); gcc_assert (DECL_INITIAL (fn_decl)); DECL_SAVED_TREE (fn_decl) = NULL_TREE; - node = cgraph_node (fn_decl); + node = cgraph_get_create_node (fn_decl); /* Read all the basic blocks. */ tag = input_record_start (ib); Index: src/gcc/lto-symtab.c =================================================================== --- src.orig/gcc/lto-symtab.c +++ src/gcc/lto-symtab.c @@ -799,7 +799,7 @@ lto_symtab_merge_cgraph_nodes_1 (void ** previously unused. Create the node. */ if (!prevailing->node) { - prevailing->node = cgraph_node (prevailing->decl); + prevailing->node = cgraph_create_node (prevailing->decl); prevailing->node->alias = true; } lto_cgraph_replace_node (e->node, prevailing->node); Index: src/gcc/cgraphbuild.c =================================================================== --- src.orig/gcc/cgraphbuild.c +++ src/gcc/cgraphbuild.c @@ -74,9 +74,9 @@ record_reference (tree *tp, int *walk_su if (TREE_CODE (decl) == FUNCTION_DECL) { if (!ctx->only_vars) - cgraph_mark_address_taken_node (cgraph_node (decl)); + cgraph_mark_address_taken_node (cgraph_get_create_node (decl)); ipa_record_reference (NULL, ctx->varpool_node, - cgraph_node (decl), NULL, + cgraph_get_node (decl), NULL, IPA_REF_ADDR, NULL); } @@ -149,8 +149,8 @@ record_eh_tables (struct cgraph_node *no if (DECL_FUNCTION_PERSONALITY (node->decl)) ipa_record_reference (node, NULL, - cgraph_node (DECL_FUNCTION_PERSONALITY (node->decl)), - NULL, IPA_REF_ADDR, NULL); + cgraph_get_create_node (DECL_FUNCTION_PERSONALITY (node->decl)), + NULL, IPA_REF_ADDR, NULL); i = fun->eh->region_tree; if (!i) @@ -250,7 +250,7 @@ mark_address (gimple stmt, tree addr, vo addr = get_base_address (addr); if (TREE_CODE (addr) == FUNCTION_DECL) { - struct cgraph_node *node = cgraph_node (addr); + struct cgraph_node *node = cgraph_get_create_node (addr); cgraph_mark_address_taken_node (node); ipa_record_reference ((struct cgraph_node *)data, NULL, node, NULL, @@ -285,7 +285,7 @@ mark_load (gimple stmt, tree t, void *da { /* ??? This can happen on platforms with descriptors when these are directly manipulated in the code. Pretend that it's an address. */ - struct cgraph_node *node = cgraph_node (t); + struct cgraph_node *node = cgraph_get_create_node (t); cgraph_mark_address_taken_node (node); ipa_record_reference ((struct cgraph_node *)data, NULL, node, NULL, @@ -361,9 +361,8 @@ build_cgraph_edges (void) bb); decl = gimple_call_fndecl (stmt); if (decl) - cgraph_create_edge (node, cgraph_node (decl), stmt, - bb->count, freq, - bb->loop_depth); + cgraph_create_edge (node, cgraph_get_create_node (decl), + stmt, bb->count, freq, bb->loop_depth); else cgraph_create_indirect_edge (node, stmt, gimple_call_flags (stmt), @@ -376,18 +375,18 @@ build_cgraph_edges (void) && gimple_omp_parallel_child_fn (stmt)) { tree fn = gimple_omp_parallel_child_fn (stmt); - ipa_record_reference (node, NULL, cgraph_node (fn), + ipa_record_reference (node, NULL, cgraph_get_create_node (fn), NULL, IPA_REF_ADDR, stmt); } if (gimple_code (stmt) == GIMPLE_OMP_TASK) { tree fn = gimple_omp_task_child_fn (stmt); if (fn) - ipa_record_reference (node, NULL, cgraph_node (fn), + ipa_record_reference (node, NULL, cgraph_get_create_node (fn), NULL, IPA_REF_ADDR, stmt); fn = gimple_omp_task_copy_fn (stmt); if (fn) - ipa_record_reference (node, NULL, cgraph_node (fn), + ipa_record_reference (node, NULL, cgraph_get_create_node (fn), NULL, IPA_REF_ADDR, stmt); } } @@ -472,9 +471,8 @@ rebuild_cgraph_edges (void) bb); decl = gimple_call_fndecl (stmt); if (decl) - cgraph_create_edge (node, cgraph_node (decl), stmt, - bb->count, freq, - bb->loop_depth); + cgraph_create_edge (node, cgraph_get_create_node (decl), stmt, + bb->count, freq, bb->loop_depth); else cgraph_create_indirect_edge (node, stmt, gimple_call_flags (stmt), Index: src/gcc/cgraphunit.c =================================================================== --- src.orig/gcc/cgraphunit.c +++ src/gcc/cgraphunit.c @@ -343,7 +343,7 @@ cgraph_lower_function (struct cgraph_nod void cgraph_finalize_function (tree decl, bool nested) { - struct cgraph_node *node = cgraph_node (decl); + struct cgraph_node *node = cgraph_get_create_node (decl); if (node->local.finalized) cgraph_reset_node (node); @@ -1990,7 +1990,7 @@ cgraph_copy_node_for_versioning (struct gcc_assert (old_version); - new_version = cgraph_node (new_decl); + new_version = cgraph_create_node (new_decl); new_version->analyzed = true; new_version->local = old_version->local; Index: src/gcc/cp/class.c =================================================================== --- src.orig/gcc/cp/class.c +++ src/gcc/cp/class.c @@ -8401,7 +8401,7 @@ cp_fold_obj_type_ref (tree ref, tree kno DECL_VINDEX (fndecl))); #endif - cgraph_node (fndecl)->local.vtable_method = true; + cgraph_get_create_node (fndecl)->local.vtable_method = true; return build_address (fndecl); } Index: src/gcc/cp/decl2.c =================================================================== --- src.orig/gcc/cp/decl2.c +++ src/gcc/cp/decl2.c @@ -3374,11 +3374,13 @@ cxx_callgraph_analyze_expr (tree *tp, in { case PTRMEM_CST: if (TYPE_PTRMEMFUNC_P (TREE_TYPE (t))) - cgraph_mark_address_taken_node (cgraph_node (PTRMEM_CST_MEMBER (t))); + cgraph_mark_address_taken_node ( + cgraph_get_create_node (PTRMEM_CST_MEMBER (t))); break; case BASELINK: if (TREE_CODE (BASELINK_FUNCTIONS (t)) == FUNCTION_DECL) - cgraph_mark_address_taken_node (cgraph_node (BASELINK_FUNCTIONS (t))); + cgraph_mark_address_taken_node ( + cgraph_get_create_node (BASELINK_FUNCTIONS (t))); break; case VAR_DECL: if (DECL_CONTEXT (t) @@ -3891,7 +3893,7 @@ cp_write_global_declarations (void) if (!DECL_EXTERNAL (decl) && decl_needed_p (decl) && !TREE_ASM_WRITTEN (decl) - && !cgraph_node (decl)->local.finalized) + && !cgraph_get_create_node (decl)->local.finalized) { /* We will output the function; no longer consider it in this loop. */ Index: src/gcc/cp/optimize.c =================================================================== --- src.orig/gcc/cp/optimize.c +++ src/gcc/cp/optimize.c @@ -309,7 +309,8 @@ maybe_clone_body (tree fn) && (!DECL_ONE_ONLY (fns[0]) || (HAVE_COMDAT_GROUP && DECL_WEAK (fns[0]))) - && cgraph_same_body_alias (cgraph_node (fns[0]), clone, fns[0])) + && cgraph_same_body_alias (cgraph_get_create_node (fns[0]), clone, + fns[0])) { alias = true; if (DECL_ONE_ONLY (fns[0])) @@ -423,8 +424,8 @@ maybe_clone_body (tree fn) /* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is virtual, it goes into the same comdat group as well. */ DECL_COMDAT_GROUP (fns[2]) = comdat_group; - base_dtor_node = cgraph_node (fns[0]); - deleting_dtor_node = cgraph_node (fns[2]); + base_dtor_node = cgraph_get_create_node (fns[0]); + deleting_dtor_node = cgraph_get_create_node (fns[2]); gcc_assert (base_dtor_node->same_comdat_group == NULL); gcc_assert (deleting_dtor_node->same_comdat_group == NULL); base_dtor_node->same_comdat_group = deleting_dtor_node; Index: src/gcc/cp/semantics.c =================================================================== --- src.orig/gcc/cp/semantics.c +++ src/gcc/cp/semantics.c @@ -8426,8 +8426,8 @@ maybe_add_lambda_conv_op (tree type) /* Put the thunk in the same comdat group as the call op. */ struct cgraph_node *callop_node, *thunk_node; DECL_COMDAT_GROUP (statfn) = DECL_COMDAT_GROUP (callop); - callop_node = cgraph_node (callop); - thunk_node = cgraph_node (statfn); + callop_node = cgraph_get_create_node (callop); + thunk_node = cgraph_get_create_node (statfn); gcc_assert (callop_node->same_comdat_group == NULL); gcc_assert (thunk_node->same_comdat_group == NULL); callop_node->same_comdat_group = thunk_node; Index: src/gcc/varasm.c =================================================================== --- src.orig/gcc/varasm.c +++ src/gcc/varasm.c @@ -2234,7 +2234,7 @@ mark_decl_referenced (tree decl) If we know a method will be emitted in other TU and no new functions can be marked reachable, just use the external definition. */ - struct cgraph_node *node = cgraph_node (decl); + struct cgraph_node *node = cgraph_get_create_node (decl); if (!DECL_EXTERNAL (decl) && (!node->local.vtable_method || !cgraph_global_info_ready || !node->local.finalized)) @@ -5842,7 +5842,7 @@ assemble_alias (tree decl, tree target) /* Allow aliases to aliases. */ if (TREE_CODE (decl) == FUNCTION_DECL) - cgraph_node (decl)->alias = true; + cgraph_get_create_node (decl)->alias = true; else varpool_node (decl)->alias = true; Index: src/gcc/ada/gcc-interface/utils.c =================================================================== --- src.orig/gcc/ada/gcc-interface/utils.c +++ src/gcc/ada/gcc-interface/utils.c @@ -2003,7 +2003,7 @@ end_subprog_body (tree body) else /* Register this function with cgraph just far enough to get it added to our parent's nested function list. */ - (void) cgraph_node (fndecl); + (void) cgraph_get_create_node (fndecl); } tree Index: src/gcc/fortran/trans-decl.c =================================================================== --- src.orig/gcc/fortran/trans-decl.c +++ src/gcc/fortran/trans-decl.c @@ -5064,7 +5064,7 @@ gfc_generate_function_code (gfc_namespac if (decl_function_context (fndecl)) /* Register this function with cgraph just far enough to get it added to our parent's nested function list. */ - (void) cgraph_node (fndecl); + (void) cgraph_get_create_node (fndecl); else cgraph_finalize_function (fndecl, true); Index: src/gcc/objc/objc-act.c =================================================================== --- src.orig/gcc/objc/objc-act.c +++ src/gcc/objc/objc-act.c @@ -4519,14 +4519,16 @@ mark_referenced_methods (void) chain = CLASS_CLS_METHODS (impent->imp_context); while (chain) { - cgraph_mark_needed_node (cgraph_node (METHOD_DEFINITION (chain))); + cgraph_mark_needed_node ( + cgraph_get_create_node (METHOD_DEFINITION (chain))); chain = DECL_CHAIN (chain); } chain = CLASS_NST_METHODS (impent->imp_context); while (chain) { - cgraph_mark_needed_node (cgraph_node (METHOD_DEFINITION (chain))); + cgraph_mark_needed_node ( + cgraph_get_create_node (METHOD_DEFINITION (chain))); chain = DECL_CHAIN (chain); } } Index: src/gcc/cp/mangle.c =================================================================== --- src.orig/gcc/cp/mangle.c +++ src/gcc/cp/mangle.c @@ -3170,7 +3170,7 @@ mangle_decl (const tree decl) if (vague_linkage_p (decl)) DECL_WEAK (alias) = 1; if (TREE_CODE (decl) == FUNCTION_DECL) - cgraph_same_body_alias (cgraph_node (decl), alias, decl); + cgraph_same_body_alias (cgraph_get_create_node (decl), alias, decl); else varpool_extra_name_alias (alias, decl); #endif Index: src/gcc/cp/method.c =================================================================== --- src.orig/gcc/cp/method.c +++ src/gcc/cp/method.c @@ -259,8 +259,9 @@ make_alias_for_thunk (tree function) if (!flag_syntax_only) { - struct cgraph_node *aliasn = cgraph_same_body_alias (cgraph_node (function), - alias, function); + struct cgraph_node *aliasn; + aliasn = cgraph_same_body_alias (cgraph_get_create_node (function), + alias, function); DECL_ASSEMBLER_NAME (function); gcc_assert (aliasn != NULL); } @@ -378,7 +379,7 @@ use_thunk (tree thunk_fndecl, bool emit_ a = nreverse (t); DECL_ARGUMENTS (thunk_fndecl) = a; TREE_ASM_WRITTEN (thunk_fndecl) = 1; - cgraph_add_thunk (cgraph_node (function), thunk_fndecl, function, + cgraph_add_thunk (cgraph_get_create_node (function), thunk_fndecl, function, this_adjusting, fixed_offset, virtual_value, virtual_offset, alias); ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/7] Removal of cgraph_node function 2011-04-06 23:26 ` [PATCH 4/7] Removal of cgraph_node function Martin Jambor @ 2011-04-11 10:28 ` Jan Hubicka 2011-04-11 14:15 ` Martin Jambor 0 siblings, 1 reply; 16+ messages in thread From: Jan Hubicka @ 2011-04-11 10:28 UTC (permalink / raw) To: Martin Jambor; +Cc: GCC Patches, Jan Hubicka > 2011-04-06 Martin Jambor <mjambor@suse.cz> > > * cgraph.h (cgraph_node): Remove function declaration. > (cgraph_create_node): Declare. > (cgraph_get_create_node): Likewise. > > * cgraph.c (cgraph_create_node): Renamed to cgraph_create_node_1. > Updated all callers. > (cgraph_node): Renamed to cgraph_create_node, assert that a node for > the decl does not already exist. Call cgraph_get_create_node instead > of cgraph_node. > (cgraph_get_create_node): New function. > (cgraph_same_body_alias): Update comment. > (cgraph_set_call_stmt): Call cgraph_get_node instead of cgraph_node, > assert it does not return NULL. > (cgraph_update_edges_for_call_stmt): Likewise. > (cgraph_clone_edge): Likewise. > (cgraph_create_virtual_clone): Likewise. > (cgraph_update_edges_for_call_stmt_node): Call cgraph_get_create_node > instead of cgraph_node. > (cgraph_add_new_function): Call cgraph_create_node or > cgraph_get_create_node instead of cgraph_node. > > * cgraphbuild.c (record_reference): Call cgraph_get_create_node > instead of cgraph_node. > (record_eh_tables): Likewise. > (mark_address): Likewise. > (mark_load): Likewise. > (build_cgraph_edges): Call cgraph_get_create_node instead > of cgraph_node. > (rebuild_cgraph_edges): Likewise. > > * cgraphunit.c (cgraph_finalize_function): Call cgraph_get_create_node > instead of cgraph_node. > (cgraph_copy_node_for_versioning): Call cgraph_create_node instead of > cgraph_node. > > * lto-symtab.c (lto_symtab_merge_cgraph_nodes_1): Call > cgraph_create_node instead of cgraph_node. > > * c-decl.c (finish_function): Call cgraph_get_create_node instead > of cgraph_node. > * lto-cgraph.c (input_node): Likewise. > * lto-streamer-in.c (input_function): Likewise. > * varasm.c (mark_decl_referenced): Likewise. > (assemble_alias): Likewise. > > gcc/c-family/ > * c-gimplify.c (c_genericize): Call cgraph_get_create_node instead > of cgraph_node. > > gcc/cp/ > * cp/class.c (cp_fold_obj_type_ref): Call cgraph_get_create_node > instead of cgraph_node. > * cp/decl2.c (cxx_callgraph_analyze_expr): Likewise. > (cp_write_global_declarations): Likewise. > * cp/optimize.c (maybe_clone_body): Likewise. > * cp/semantics.c (maybe_add_lambda_conv_op): Likewise. > * cp/mangle.c (mangle_decl): Likewise. > * cp/method.c (make_alias_for_thunk): Likewise. > (use_thunk): Likewise. > > gcc/ada/ > * gcc-interface/utils.c (end_subprog_body): Call > cgraph_get_create_node instead of cgraph_node. > > gcc/fortran/ > * trans-decl.c (gfc_generate_function_code): Call > cgraph_get_create_node instead of cgraph_node. > > gcc/objc/ > * objc-act.c (mark_referenced_methods): Call cgraph_get_create_node > instead of cgraph_node. OK. > Index: src/gcc/lto-cgraph.c > =================================================================== > --- src.orig/gcc/lto-cgraph.c > +++ src/gcc/lto-cgraph.c > @@ -1045,7 +1045,7 @@ input_node (struct lto_file_decl_data *f > 0, CGRAPH_FREQ_BASE, 0, false, NULL); > } > else > - node = cgraph_node (fn_decl); > + node = cgraph_get_create_node (fn_decl); > > node->count = lto_input_sleb128 (ib); > node->count_materialization_scale = lto_input_sleb128 (ib); > Index: src/gcc/lto-streamer-in.c > =================================================================== > --- src.orig/gcc/lto-streamer-in.c > +++ src/gcc/lto-streamer-in.c > @@ -1301,7 +1301,7 @@ input_function (tree fn_decl, struct dat > DECL_INITIAL (fn_decl) = lto_input_tree (ib, data_in); > gcc_assert (DECL_INITIAL (fn_decl)); > DECL_SAVED_TREE (fn_decl) = NULL_TREE; > - node = cgraph_node (fn_decl); > + node = cgraph_get_create_node (fn_decl); I would expect those two to be cgraph_create_node and cgraph_get_node or we have latent bug somewhere. Did you have particular reason for the choice here? I guess we can handle this incrementally. > Index: src/gcc/cgraphbuild.c > =================================================================== > --- src.orig/gcc/cgraphbuild.c > +++ src/gcc/cgraphbuild.c > @@ -74,9 +74,9 @@ record_reference (tree *tp, int *walk_su > if (TREE_CODE (decl) == FUNCTION_DECL) > { > if (!ctx->only_vars) > - cgraph_mark_address_taken_node (cgraph_node (decl)); > + cgraph_mark_address_taken_node (cgraph_get_create_node (decl)); > ipa_record_reference (NULL, ctx->varpool_node, > - cgraph_node (decl), NULL, > + cgraph_get_node (decl), NULL, Please CSE the cgraph_get_create_node call here. In both cases we want get_create_node, during the later cgraph builds the new nodes ight become needed as result of devirtualization and external construvctor folding. Honza ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/7] Removal of cgraph_node function 2011-04-11 10:28 ` Jan Hubicka @ 2011-04-11 14:15 ` Martin Jambor 0 siblings, 0 replies; 16+ messages in thread From: Martin Jambor @ 2011-04-11 14:15 UTC (permalink / raw) To: Jan Hubicka; +Cc: GCC Patches Hi, On Mon, Apr 11, 2011 at 12:28:36PM +0200, Jan Hubicka wrote: > > 2011-04-06 Martin Jambor <mjambor@suse.cz> > > > > * cgraph.h (cgraph_node): Remove function declaration. > > (cgraph_create_node): Declare. > > (cgraph_get_create_node): Likewise. > > > > * cgraph.c (cgraph_create_node): Renamed to cgraph_create_node_1. > > Updated all callers. > > (cgraph_node): Renamed to cgraph_create_node, assert that a node for > > the decl does not already exist. Call cgraph_get_create_node instead > > of cgraph_node. > > (cgraph_get_create_node): New function. > > (cgraph_same_body_alias): Update comment. > > (cgraph_set_call_stmt): Call cgraph_get_node instead of cgraph_node, > > assert it does not return NULL. > > (cgraph_update_edges_for_call_stmt): Likewise. > > (cgraph_clone_edge): Likewise. > > (cgraph_create_virtual_clone): Likewise. > > (cgraph_update_edges_for_call_stmt_node): Call cgraph_get_create_node > > instead of cgraph_node. > > (cgraph_add_new_function): Call cgraph_create_node or > > cgraph_get_create_node instead of cgraph_node. > > > > * cgraphbuild.c (record_reference): Call cgraph_get_create_node > > instead of cgraph_node. > > (record_eh_tables): Likewise. > > (mark_address): Likewise. > > (mark_load): Likewise. > > (build_cgraph_edges): Call cgraph_get_create_node instead > > of cgraph_node. > > (rebuild_cgraph_edges): Likewise. > > > > * cgraphunit.c (cgraph_finalize_function): Call cgraph_get_create_node > > instead of cgraph_node. > > (cgraph_copy_node_for_versioning): Call cgraph_create_node instead of > > cgraph_node. > > > > * lto-symtab.c (lto_symtab_merge_cgraph_nodes_1): Call > > cgraph_create_node instead of cgraph_node. > > > > * c-decl.c (finish_function): Call cgraph_get_create_node instead > > of cgraph_node. > > * lto-cgraph.c (input_node): Likewise. > > * lto-streamer-in.c (input_function): Likewise. > > * varasm.c (mark_decl_referenced): Likewise. > > (assemble_alias): Likewise. > > > > gcc/c-family/ > > * c-gimplify.c (c_genericize): Call cgraph_get_create_node instead > > of cgraph_node. > > > > gcc/cp/ > > * cp/class.c (cp_fold_obj_type_ref): Call cgraph_get_create_node > > instead of cgraph_node. > > * cp/decl2.c (cxx_callgraph_analyze_expr): Likewise. > > (cp_write_global_declarations): Likewise. > > * cp/optimize.c (maybe_clone_body): Likewise. > > * cp/semantics.c (maybe_add_lambda_conv_op): Likewise. > > * cp/mangle.c (mangle_decl): Likewise. > > * cp/method.c (make_alias_for_thunk): Likewise. > > (use_thunk): Likewise. > > > > gcc/ada/ > > * gcc-interface/utils.c (end_subprog_body): Call > > cgraph_get_create_node instead of cgraph_node. > > > > gcc/fortran/ > > * trans-decl.c (gfc_generate_function_code): Call > > cgraph_get_create_node instead of cgraph_node. > > > > gcc/objc/ > > * objc-act.c (mark_referenced_methods): Call cgraph_get_create_node > > instead of cgraph_node. > > OK. > > Index: src/gcc/lto-cgraph.c > > =================================================================== > > --- src.orig/gcc/lto-cgraph.c > > +++ src/gcc/lto-cgraph.c > > @@ -1045,7 +1045,7 @@ input_node (struct lto_file_decl_data *f > > 0, CGRAPH_FREQ_BASE, 0, false, NULL); > > } > > else > > - node = cgraph_node (fn_decl); > > + node = cgraph_get_create_node (fn_decl); > > > > node->count = lto_input_sleb128 (ib); > > node->count_materialization_scale = lto_input_sleb128 (ib); > > Index: src/gcc/lto-streamer-in.c > > =================================================================== > > --- src.orig/gcc/lto-streamer-in.c > > +++ src/gcc/lto-streamer-in.c > > @@ -1301,7 +1301,7 @@ input_function (tree fn_decl, struct dat > > DECL_INITIAL (fn_decl) = lto_input_tree (ib, data_in); > > gcc_assert (DECL_INITIAL (fn_decl)); > > DECL_SAVED_TREE (fn_decl) = NULL_TREE; > > - node = cgraph_node (fn_decl); > > + node = cgraph_get_create_node (fn_decl); > > I would expect those two to be cgraph_create_node and cgraph_get_node or we > have latent bug somewhere. Did you have particular reason for the choice here? > I guess we can handle this incrementally. cgraph_create_node was aborting on the assert. I don't remember on which testcases(s) but they are in our testcase so we can have a look. > > Index: src/gcc/cgraphbuild.c > > =================================================================== > > --- src.orig/gcc/cgraphbuild.c > > +++ src/gcc/cgraphbuild.c > > @@ -74,9 +74,9 @@ record_reference (tree *tp, int *walk_su > > if (TREE_CODE (decl) == FUNCTION_DECL) > > { > > if (!ctx->only_vars) > > - cgraph_mark_address_taken_node (cgraph_node (decl)); > > + cgraph_mark_address_taken_node (cgraph_get_create_node (decl)); > > ipa_record_reference (NULL, ctx->varpool_node, > > - cgraph_node (decl), NULL, > > + cgraph_get_node (decl), NULL, > > Please CSE the cgraph_get_create_node call here. In both cases we want > get_create_node, during the later cgraph builds the new nodes ight become needed > as result of devirtualization and external construvctor folding. > I see, I have changed the hunk into the following and will commit it as such after re-testing: Index: src/gcc/cgraphbuild.c =================================================================== --- src.orig/gcc/cgraphbuild.c +++ src/gcc/cgraphbuild.c @@ -73,10 +73,10 @@ record_reference (tree *tp, int *walk_su decl = get_base_var (*tp); if (TREE_CODE (decl) == FUNCTION_DECL) { + struct cgraph_node *node = cgraph_get_create_node (decl); if (!ctx->only_vars) - cgraph_mark_address_taken_node (cgraph_node (decl)); - ipa_record_reference (NULL, ctx->varpool_node, - cgraph_node (decl), NULL, + cgraph_mark_address_taken_node (node); + ipa_record_reference (NULL, ctx->varpool_node, node, NULL, IPA_REF_ADDR, NULL); } Thanks, Martin ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/7] A tweak to fortran -> call graph interface 2011-04-06 23:25 [PATCH 0/7] Change of call graph interface - cgraph_node function removal Martin Jambor ` (5 preceding siblings ...) 2011-04-06 23:26 ` [PATCH 4/7] Removal of cgraph_node function Martin Jambor @ 2011-04-06 23:26 ` Martin Jambor 6 siblings, 0 replies; 16+ messages in thread From: Martin Jambor @ 2011-04-06 23:26 UTC (permalink / raw) To: GCC Patches; +Cc: Jan Hubicka [-- Attachment #1: cgraph_fortran_calls.diff --] [-- Type: text/plain, Size: 918 bytes --] Hi, it seems to me that fortran can call cgraph_create_node directly without checking for its existence first. Bootstrapped and tested on x86_64-linux without any problems, tests on i686 in progress. Thanks, Martin 2011-03-18 Martin Jambor <mjambor@suse.cz> * trans-decl.c (gfc_generate_function_code): Call cgraph_create_node instead of cgraph_get_create_node. Index: src/gcc/fortran/trans-decl.c =================================================================== --- src.orig/gcc/fortran/trans-decl.c +++ src/gcc/fortran/trans-decl.c @@ -5064,7 +5064,7 @@ gfc_generate_function_code (gfc_namespac if (decl_function_context (fndecl)) /* Register this function with cgraph just far enough to get it added to our parent's nested function list. */ - (void) cgraph_get_create_node (fndecl); + (void) cgraph_create_node (fndecl); else cgraph_finalize_function (fndecl, true); ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2011-04-13 13:09 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-04-06 23:25 [PATCH 0/7] Change of call graph interface - cgraph_node function removal Martin Jambor 2011-04-06 23:26 ` [PATCH 3/7] cgraph_node -> cgraph_get_node with asserts Martin Jambor 2011-04-11 10:20 ` Jan Hubicka 2011-04-06 23:26 ` [PATCH 5/7] Tweaks to C++ -> call graph interface Martin Jambor 2011-04-11 15:30 ` Jason Merrill 2011-04-06 23:26 ` [PATCH 2/7] cgraph_node -> cgraph_get_node conversions accepting NULL results Martin Jambor 2011-04-11 10:18 ` Jan Hubicka 2011-04-11 13:33 ` Martin Jambor 2011-04-06 23:26 ` [PATCH 7/7] Tweaks to objc -> call graph interface Martin Jambor 2011-04-06 23:26 ` [PATCH 1/7] Simple cgraph_node -> cgraph_get_node conversions Martin Jambor 2011-04-11 10:13 ` Jan Hubicka 2011-04-13 13:09 ` H.J. Lu 2011-04-06 23:26 ` [PATCH 4/7] Removal of cgraph_node function Martin Jambor 2011-04-11 10:28 ` Jan Hubicka 2011-04-11 14:15 ` Martin Jambor 2011-04-06 23:26 ` [PATCH 6/7] A tweak to fortran -> call graph interface Martin Jambor
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).