------- Comment #14 from hubicka at ucw dot cz 2006-08-20 13:12 ------- Subject: Re: externally_visible attribute not effective with prior declaration of symbol.
Hi, this is patch I am testing now. Can you think of way to break it (again? :)) The whole thing is a lot more sliperly than I would like it to be... Honza Index: cgraphunit.c =================================================================== *** cgraphunit.c (revision 116257) --- cgraphunit.c (working copy) *************** cgraph_analyze_function (struct cgraph_n *** 965,975 **** is valid. So, we walk the nodes at the end of the translation unit, applying the ! attributes at that point. */ static void process_function_and_variable_attributes (struct cgraph_node *first, ! struct cgraph_varpool_node *first_var) { struct cgraph_node *node; struct cgraph_varpool_node *vnode; --- 985,1002 ---- is valid. So, we walk the nodes at the end of the translation unit, applying the ! attributes at that point. ! ! The local variables needs to be walked on the end of each compilation unit ! (to allow dead function/variable removal), while the global variables needs ! to be handled on the end of compilation to allow flags to be declared only ! in one of units. The GLOBAL is used to specify whether local or global ! variables shall be processed. */ static void process_function_and_variable_attributes (struct cgraph_node *first, ! struct cgraph_varpool_node *first_var, ! bool global) { struct cgraph_node *node; struct cgraph_varpool_node *vnode; *************** process_function_and_variable_attributes *** 977,982 **** --- 1004,1012 ---- for (node = cgraph_nodes; node != first; node = node->next) { tree decl = node->decl; + if (global != (DECL_COMDAT (decl) + || (TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl)))) + continue; if (lookup_attribute ("used", DECL_ATTRIBUTES (decl))) { mark_decl_referenced (decl); *************** process_function_and_variable_attributes *** 1000,1005 **** --- 1030,1037 ---- for (vnode = cgraph_varpool_nodes; vnode != first_var; vnode = vnode->next) { tree decl = vnode->decl; + if (global != (DECL_COMDAT (decl) || TREE_PUBLIC (decl))) + continue; if (lookup_attribute ("used", DECL_ATTRIBUTES (decl))) { mark_decl_referenced (decl); *************** cgraph_finalize_compilation_unit (void) *** 1052,1058 **** } timevar_push (TV_CGRAPH); ! process_function_and_variable_attributes (first_analyzed, first_analyzed_var); cgraph_varpool_analyze_pending_decls (); if (cgraph_dump_file) { --- 1085,1092 ---- } timevar_push (TV_CGRAPH); ! process_function_and_variable_attributes (first_analyzed, first_analyzed_var, ! false); cgraph_varpool_analyze_pending_decls (); if (cgraph_dump_file) { *************** cgraph_optimize (void) *** 1505,1512 **** timevar_push (TV_CGRAPHOPT); if (!quiet_flag) ! fprintf (stderr, "Performing intraprocedural optimizations\n"); cgraph_function_and_variable_visibility (); if (cgraph_dump_file) { --- 1540,1548 ---- timevar_push (TV_CGRAPHOPT); if (!quiet_flag) ! fprintf (stderr, "Performing interprocedural optimizations\n"); + process_function_and_variable_attributes (NULL, NULL, true); cgraph_function_and_variable_visibility (); if (cgraph_dump_file) { -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28744