diff mbox

[google] fix for undefined location list symbol in LIPO (issue5355042)

Message ID 20111104171313.E19E2C2525@rong.mtv.corp.google.com
State New
Headers show

Commit Message

Rong Xu Nov. 4, 2011, 5:13 p.m. UTC
Don't emit the type info if a function's context type is not 
output.

For google branch only.

Tested with internal benchmark suite with -g.

2011-11-04   Rong Xu  <xur@google.com>

	* gcc/dwarf2out.c (dwarf2out_decl): not emit type info
          for unreachable functions in LIPO mode.


--
This patch is available for review at http://codereview.appspot.com/5355042

Comments

Xinliang David Li Nov. 4, 2011, 5:41 p.m. UTC | #1
Ok for google branches.

David

On Fri, Nov 4, 2011 at 10:13 AM, Rong Xu <xur@google.com> wrote:
> Don't emit the type info if a function's context type is not
> output.
>
> For google branch only.
>
> Tested with internal benchmark suite with -g.
>
> 2011-11-04   Rong Xu  <xur@google.com>
>
>        * gcc/dwarf2out.c (dwarf2out_decl): not emit type info
>          for unreachable functions in LIPO mode.
>
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c     (revision 180964)
> +++ gcc/dwarf2out.c     (working copy)
> @@ -95,6 +95,7 @@
>  #include "tree-flow.h"
>  #include "cfglayout.h"
>  #include "opts.h"
> +#include "l-ipo.h"
>
>  static void dwarf2out_source_line (unsigned int, const char *, int, bool);
>  static rtx last_var_location_insn;
> @@ -19745,6 +19746,39 @@
>  void
>  dwarf2out_decl (tree decl)
>  {
> +  /* In LIPO mode, we may output some functions whose type is defined
> +     in another function that will not be output. This can result in
> +     undefined location list symbols in the debug type info.
> +     Here we disable the output of the type info for this case.
> +     It is safe since this function and its debug info should never
> +     be referenced.  */
> +  if (L_IPO_COMP_MODE)
> +    {
> +      tree decl_context, orig_decl;
> +
> +      decl_context = DECL_CONTEXT (decl);
> +      while (decl_context &&
> +          TREE_CODE (decl_context) != TRANSLATION_UNIT_DECL)
> +      {
> +        struct cgraph_node *node;
> +
> +        orig_decl = DECL_ORIGIN (decl_context);
> +        while (orig_decl != DECL_ORIGIN (orig_decl))
> +          orig_decl = DECL_ORIGIN (orig_decl);
> +
> +        /* Refer to cgraph_mark_functions_to_output() in cgraphunit.c,
> +           if cgraph_is_aux_decl_external() is true,
> +           this function will not be output in LIPO mode.  */
> +        if (TREE_CODE (decl_context) == FUNCTION_DECL &&
> +            TREE_PUBLIC (decl_context) &&
> +            (node = cgraph_get_node (decl_context)) &&
> +            cgraph_is_aux_decl_external (node))
> +          return;
> +
> +        decl_context = DECL_CONTEXT (orig_decl);
> +      }
> +    }
> +
>   dw_die_ref context_die = comp_unit_die ();
>
>   switch (TREE_CODE (decl))
>
> --
> This patch is available for review at http://codereview.appspot.com/5355042
>
Diego Novillo Nov. 4, 2011, 7:26 p.m. UTC | #2
On Fri, Nov 4, 2011 at 13:13, Rong Xu <xur@google.com> wrote:
> Don't emit the type info if a function's context type is not
> output.
>
> For google branch only.
>
> Tested with internal benchmark suite with -g.
>
> 2011-11-04   Rong Xu  <xur@google.com>
>
>        * gcc/dwarf2out.c (dwarf2out_decl): not emit type info
>          for unreachable functions in LIPO mode.
>
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c     (revision 180964)
> +++ gcc/dwarf2out.c     (working copy)
> @@ -95,6 +95,7 @@
>  #include "tree-flow.h"
>  #include "cfglayout.h"
>  #include "opts.h"
> +#include "l-ipo.h"
>
>  static void dwarf2out_source_line (unsigned int, const char *, int, bool);
>  static rtx last_var_location_insn;
> @@ -19745,6 +19746,39 @@
>  void
>  dwarf2out_decl (tree decl)
>  {
> +  /* In LIPO mode, we may output some functions whose type is defined
> +     in another function that will not be output. This can result in
> +     undefined location list symbols in the debug type info.
> +     Here we disable the output of the type info for this case.
> +     It is safe since this function and its debug info should never
> +     be referenced.  */
> +  if (L_IPO_COMP_MODE)
> +    {
> +      tree decl_context, orig_decl;
> +
> +      decl_context = DECL_CONTEXT (decl);
> +      while (decl_context &&
> +          TREE_CODE (decl_context) != TRANSLATION_UNIT_DECL)

&& goes on the line below.

> +      {
> +        struct cgraph_node *node;
> +
> +        orig_decl = DECL_ORIGIN (decl_context);
> +        while (orig_decl != DECL_ORIGIN (orig_decl))
> +          orig_decl = DECL_ORIGIN (orig_decl);
> +
> +        /* Refer to cgraph_mark_functions_to_output() in cgraphunit.c,
> +           if cgraph_is_aux_decl_external() is true,
> +           this function will not be output in LIPO mode.  */
> +        if (TREE_CODE (decl_context) == FUNCTION_DECL &&
> +            TREE_PUBLIC (decl_context) &&
> +            (node = cgraph_get_node (decl_context)) &&
> +            cgraph_is_aux_decl_external (node))

Likewise.


Diego.
diff mbox

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 180964)
+++ gcc/dwarf2out.c	(working copy)
@@ -95,6 +95,7 @@ 
 #include "tree-flow.h"
 #include "cfglayout.h"
 #include "opts.h"
+#include "l-ipo.h"
 
 static void dwarf2out_source_line (unsigned int, const char *, int, bool);
 static rtx last_var_location_insn;
@@ -19745,6 +19746,39 @@ 
 void
 dwarf2out_decl (tree decl)
 {
+  /* In LIPO mode, we may output some functions whose type is defined
+     in another function that will not be output. This can result in
+     undefined location list symbols in the debug type info.
+     Here we disable the output of the type info for this case.
+     It is safe since this function and its debug info should never
+     be referenced.  */
+  if (L_IPO_COMP_MODE)
+    {
+      tree decl_context, orig_decl;
+
+      decl_context = DECL_CONTEXT (decl);
+      while (decl_context &&
+          TREE_CODE (decl_context) != TRANSLATION_UNIT_DECL)
+      {
+        struct cgraph_node *node;
+
+        orig_decl = DECL_ORIGIN (decl_context);
+        while (orig_decl != DECL_ORIGIN (orig_decl))
+          orig_decl = DECL_ORIGIN (orig_decl);
+
+        /* Refer to cgraph_mark_functions_to_output() in cgraphunit.c,
+           if cgraph_is_aux_decl_external() is true,
+           this function will not be output in LIPO mode.  */
+        if (TREE_CODE (decl_context) == FUNCTION_DECL &&
+            TREE_PUBLIC (decl_context) &&
+            (node = cgraph_get_node (decl_context)) &&
+            cgraph_is_aux_decl_external (node))
+          return;
+
+        decl_context = DECL_CONTEXT (orig_decl);
+      }
+    }
+
   dw_die_ref context_die = comp_unit_die ();
 
   switch (TREE_CODE (decl))