This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix PR 32344, cgraph rtl flags outdated


On Mon, Feb 1, 2010 at 12:44 PM, Alan Modra <amodra@gmail.com> wrote:
> On Sat, Jan 30, 2010 at 01:17:06PM +0100, Jan Hubicka wrote:
>> Please fix also the visibility pass in ipa.c.
>
> This patch should do that too. ?I noticed that some other backends
> test SYMBOL_REF_WEAK and that make_decl_rtl does not update that
> particular rtl flag and was unsure whether it should, so put all the
> flag twiddling into a function.
>
> Bootstrapped and regression tested powerpc-linux and i686-linux.

Ok.

Thanks,
Richard.

> ? ? ? ?PR middle-end/42344
> ? ? ? ?* cgraph.h (cgraph_make_decl_local): Declare.
> ? ? ? ?* cgraph.c (cgraph_make_decl_local): New function.
> ? ? ? ?(cgraph_make_node_local): Use it.
> ? ? ? ?* cgraphunit.c (cgraph_function_versioning): Likewise.
> ? ? ? ?* ipa.c (function_and_variable_visibility): Likewise.
>
> Index: gcc/cgraph.c
> ===================================================================
> --- gcc/cgraph.c ? ? ? ?(revision 156365)
> +++ gcc/cgraph.c ? ? ? ?(working copy)
> @@ -86,6 +86,7 @@ The callgraph:
> ?#include "value-prof.h"
> ?#include "except.h"
> ?#include "diagnostic.h"
> +#include "rtl.h"
>
> ?static void cgraph_node_remove_callers (struct cgraph_node *node);
> ?static inline void cgraph_edge_remove_caller (struct cgraph_edge *e);
> @@ -2190,6 +2191,42 @@ cgraph_node_can_be_local_p (struct cgrap
> ? ? ? ? ? ? ?|| !node->local.externally_visible));
> ?}
>
> +/* Make DECL local. ?FIXME: We shouldn't need to mess with rtl this early,
> + ? but other code such as notice_global_symbol generates rtl. ?*/
> +void
> +cgraph_make_decl_local (tree decl)
> +{
> + ?rtx rtl, symbol;
> +
> + ?if (TREE_CODE (decl) == VAR_DECL)
> + ? ?DECL_COMMON (decl) = 0;
> + ?else if (TREE_CODE (decl) == FUNCTION_DECL)
> + ? ?{
> + ? ? ?DECL_COMDAT (decl) = 0;
> + ? ? ?DECL_COMDAT_GROUP (decl) = 0;
> + ? ? ?DECL_WEAK (decl) = 0;
> + ? ? ?DECL_EXTERNAL (decl) = 0;
> + ? ?}
> + ?else
> + ? ?gcc_unreachable ();
> + ?TREE_PUBLIC (decl) = 0;
> + ?if (!DECL_RTL_SET_P (decl))
> + ? ?return;
> +
> + ?/* Update rtl flags. ?*/
> + ?make_decl_rtl (decl);
> +
> + ?rtl = DECL_RTL (decl);
> + ?if (!MEM_P (rtl))
> + ? ?return;
> +
> + ?symbol = XEXP (rtl, 0);
> + ?if (GET_CODE (symbol) != SYMBOL_REF)
> + ? ?return;
> +
> + ?SYMBOL_REF_WEAK (symbol) = DECL_WEAK (decl);
> +}
> +
> ?/* Bring NODE local. ?*/
> ?void
> ?cgraph_make_node_local (struct cgraph_node *node)
> @@ -2198,19 +2235,11 @@ cgraph_make_node_local (struct cgraph_no
> ? if (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl))
> ? ? {
> ? ? ? struct cgraph_node *alias;
> - ? ? ?DECL_COMDAT (node->decl) = 0;
> - ? ? ?DECL_COMDAT_GROUP (node->decl) = 0;
> - ? ? ?TREE_PUBLIC (node->decl) = 0;
> - ? ? ?DECL_WEAK (node->decl) = 0;
> - ? ? ?DECL_EXTERNAL (node->decl) = 0;
> + ? ? ?cgraph_make_decl_local (node->decl);
> +
> ? ? ? for (alias = node->same_body; alias; alias = alias->next)
> - ? ? ? {
> - ? ? ? ? DECL_COMDAT (alias->decl) = 0;
> - ? ? ? ? DECL_COMDAT_GROUP (alias->decl) = 0;
> - ? ? ? ? TREE_PUBLIC (alias->decl) = 0;
> - ? ? ? ? DECL_WEAK (alias->decl) = 0;
> - ? ? ? ? DECL_EXTERNAL (alias->decl) = 0;
> - ? ? ? }
> + ? ? ? cgraph_make_decl_local (alias->decl);
> +
> ? ? ? node->local.externally_visible = false;
> ? ? ? node->local.local = true;
> ? ? ? gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL);
> Index: gcc/cgraph.h
> ===================================================================
> --- gcc/cgraph.h ? ? ? ?(revision 156365)
> +++ gcc/cgraph.h ? ? ? ?(working copy)
> @@ -565,6 +565,7 @@ void dump_varpool_node (FILE *, struct v
> ?void varpool_finalize_decl (tree);
> ?bool decide_is_variable_needed (struct varpool_node *, tree);
> ?enum availability cgraph_variable_initializer_availability (struct varpool_node *);
> +void cgraph_make_decl_local (tree);
> ?void cgraph_make_node_local (struct cgraph_node *);
> ?bool cgraph_node_can_be_local_p (struct cgraph_node *);
>
> Index: gcc/cgraphunit.c
> ===================================================================
> --- gcc/cgraphunit.c ? ?(revision 156365)
> +++ gcc/cgraphunit.c ? ?(working copy)
> @@ -2108,11 +2108,7 @@ cgraph_function_versioning (struct cgrap
> ? ? ?that is not weak also.
> ? ? ???? We cannot use COMDAT linkage because there is no
> ? ? ?ABI support for this. ?*/
> - ?DECL_EXTERNAL (new_version_node->decl) = 0;
> - ?DECL_COMDAT_GROUP (new_version_node->decl) = NULL_TREE;
> - ?TREE_PUBLIC (new_version_node->decl) = 0;
> - ?DECL_COMDAT (new_version_node->decl) = 0;
> - ?DECL_WEAK (new_version_node->decl) = 0;
> + ?cgraph_make_decl_local (new_version_node->decl);
> ? DECL_VIRTUAL_P (new_version_node->decl) = 0;
> ? new_version_node->local.externally_visible = 0;
> ? new_version_node->local.local = 1;
> Index: gcc/ipa.c
> ===================================================================
> --- gcc/ipa.c ? (revision 156365)
> +++ gcc/ipa.c ? (working copy)
> @@ -400,9 +400,7 @@ function_and_variable_visibility (bool w
> ? ? ? ? ?&& !DECL_EXTERNAL (node->decl))
> ? ? ? ?{
> ? ? ? ? ?gcc_assert (whole_program || !TREE_PUBLIC (node->decl));
> - ? ? ? ? TREE_PUBLIC (node->decl) = 0;
> - ? ? ? ? DECL_COMDAT (node->decl) = 0;
> - ? ? ? ? DECL_WEAK (node->decl) = 0;
> + ? ? ? ? cgraph_make_decl_local (node->decl);
> ? ? ? ?}
> ? ? ? node->local.local = (cgraph_only_called_directly_p (node)
> ? ? ? ? ? ? ? ? ? ? ? ? ? && node->analyzed
> @@ -431,8 +429,7 @@ function_and_variable_visibility (bool w
> ? ? ? if (!vnode->externally_visible)
> ? ? ? ?{
> ? ? ? ? ?gcc_assert (whole_program || !TREE_PUBLIC (vnode->decl));
> - ? ? ? ? TREE_PUBLIC (vnode->decl) = 0;
> - ? ? ? ? DECL_COMMON (vnode->decl) = 0;
> + ? ? ? ? cgraph_make_decl_local (vnode->decl);
> ? ? ? ?}
> ? ? ?gcc_assert (TREE_STATIC (vnode->decl));
> ? ? }
>
>
> --
> Alan Modra
> Australia Development Lab, IBM
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]