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: [GOOGLE] Check conditions before calling varpool_node


This is not correct. current_module_id is used only in FE parsing.

The real question is why the decl is created, neither static nor external?

David

On Thu, May 9, 2013 at 11:39 AM, Carrot Wei <carrot@google.com> wrote:
> This patch fixed google bug entry 6124850.
>
> The usage of varpool_node has some restrictions on the corresponding var decl.
> In LIPO mode function notice_global_symbol may call varpool_node with a decl
> that doesn't satisfy these restrictions since the function notice_global_symbol
> can be directly or indirectly called from anywhere. So we need to check if
> a decl can be safely passed into varpoo_node before calling it.
>
> Tested by ./buildit with targets x86-64 and power64 without regression.
>
> OK for google branches?
>
> thanks
> Carrot
>
>
> 2013-05-09  Guozhi Wei  <carrot@google.com>
>
>         varasm.c (notice_global_symbol): Check conditions before calling
>         varpool_node.
>
>
> Index: varasm.c
> ===================================================================
> --- varasm.c (revision 198726)
> +++ varasm.c (working copy)
> @@ -1515,13 +1515,29 @@
>        || !MEM_P (DECL_RTL (decl)))
>      return;
>
> -  if (L_IPO_COMP_MODE
> -      && ((TREE_CODE (decl) == FUNCTION_DECL
> -           && cgraph_is_auxiliary (decl))
> -          || (TREE_CODE (decl) == VAR_DECL
> -              && varpool_is_auxiliary (varpool_node (decl)))))
> -    return;
> +  if (L_IPO_COMP_MODE)
> +    {
> +      if (TREE_CODE (decl) == FUNCTION_DECL && cgraph_is_auxiliary (decl))
> + return;
>
> +      if (TREE_CODE (decl) == VAR_DECL)
> + {
> +  /* Varpool_node can only accept var decl with flags
> +     (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
> +     For decl without these flags, we need to
> +     check if it is auxiliary manually.  */
> +  if (!(TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
> +    {
> +      /* If a new varpool_node can be created,
> +         the module id is current_module_id.  */
> +      if (current_module_id != primary_module_id)
> + return;
> +    }
> +  else if (varpool_is_auxiliary (varpool_node (decl)))
> +    return;
> + }
> +    }
> +
>    /* We win when global object is found, but it is useful to know about weak
>       symbol as well so we can produce nicer unique names.  */
>    if (DECL_WEAK (decl) || DECL_ONE_ONLY (decl) || flag_shlib)


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