------- Comment #7 from hubicka at ucw dot cz 2009-10-08 14:18 ------- Subject: Re: [4.5 Regression] GCC does not bootstrap on powerpc64
Hi, the following patch should fix the problem. I am bootstrapping/regtesting it at x86_64-linux, but it would be nice to know if it actually fixes the bootstrap. It does work on reduced testcase for me. Honza * cgraphbuild.c (record_reference): When parameter DATA is NULL, do not mark cgraph nodes as needed. (record_references_in_initializer): Add new only_vars parameter. * cgraph.h (record_references_in_initializer): New parameter. * varasm.c (assemble_variable): Update call. * varpool.c (varpool_analyze_pending_decls): Always look for referenced vars. Index: cgraphbuild.c =================================================================== --- cgraphbuild.c (revision 152557) +++ cgraphbuild.c (working copy) @@ -33,13 +33,16 @@ along with GCC; see the file COPYING3. #include "tree-pass.h" /* Walk tree and record all calls and references to functions/variables. - Called via walk_tree: TP is pointer to tree to be examined. */ + Called via walk_tree: TP is pointer to tree to be examined. + When DATA is non-null, record references to callgraph. + */ static tree -record_reference (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) +record_reference (tree *tp, int *walk_subtrees, void *data) { tree t = *tp; tree decl; + bool do_callgraph = data != NULL; switch (TREE_CODE (t)) { @@ -57,7 +60,7 @@ record_reference (tree *tp, int *walk_su /* Record dereferences to the functions. This makes the functions reachable unconditionally. */ decl = TREE_OPERAND (*tp, 0); - if (TREE_CODE (decl) == FUNCTION_DECL) + if (TREE_CODE (decl) == FUNCTION_DECL && do_callgraph) cgraph_mark_address_taken_node (cgraph_node (decl)); break; @@ -218,13 +221,15 @@ struct gimple_opt_pass pass_build_cgraph }; /* Record references to functions and other variables present in the - initial value of DECL, a variable. */ + initial value of DECL, a variable. + When ONLY_VARS is true, we mark needed only variables, not functions. */ void -record_references_in_initializer (tree decl) +record_references_in_initializer (tree decl, bool only_vars) { struct pointer_set_t *visited_nodes = pointer_set_create (); - walk_tree (&DECL_INITIAL (decl), record_reference, NULL, visited_nodes); + walk_tree (&DECL_INITIAL (decl), record_reference, + only_vars ? NULL : decl, visited_nodes); pointer_set_destroy (visited_nodes); } Index: cgraph.h =================================================================== --- cgraph.h (revision 152557) +++ cgraph.h (working copy) @@ -459,7 +459,7 @@ struct cgraph_node *cgraph_function_vers bitmap); void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap); struct cgraph_node *save_inline_function_body (struct cgraph_node *); -void record_references_in_initializer (tree); +void record_references_in_initializer (tree, bool); bool cgraph_process_new_functions (void); bool cgraph_decide_is_function_needed (struct cgraph_node *, tree); Index: varasm.c =================================================================== --- varasm.c (revision 152557) +++ varasm.c (working copy) @@ -2082,7 +2082,7 @@ assemble_variable (tree decl, int top_le Without this, if the variable is placed in a section-anchored block, the template will only be marked when it's too late. */ - record_references_in_initializer (to); + record_references_in_initializer (to, false); } decl = to; Index: varpool.c =================================================================== --- varpool.c (revision 152557) +++ varpool.c (working copy) @@ -365,9 +365,9 @@ varpool_analyze_pending_decls (void) already informed about increased alignment. */ align_variable (decl, 0); - if (DECL_INITIAL (decl)) - record_references_in_initializer (decl); } + if (DECL_INITIAL (decl)) + record_references_in_initializer (decl, analyzed); changed = true; } timevar_pop (TV_CGRAPH); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41626