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]

PR middle-end/30700 (optimized out function referenced by debug info)


Hi,
this patch should fix PR30700 where function is optimized out but still
referenced by debug info. I've tried to be abit defensive, since there
seems to be a lot of things that might go wrong here and the sanity
checks caught at least a case where reference_to_unused is called for
non VAR_DECL/FUNCTION_DECL (during .pch compilation of libstdc++) where
varpool was orginally incorrectly asked.  So I hope we are relatively
safe now.

I've also verified that the output assembly does not change for some of C and
C++ units I had around.

Bootstrapped/regtested i686-linux, OK for mainline and release branches?

Honza

	PR middle-end/PR30700
	* dwarf2out.c (reference_to_unused): Ask cgraph for functions 
	availablility; add more sanity checking; ask varpool only about
	VAR_DECL.
Index: dwarf2out.c
===================================================================
*** dwarf2out.c	(revision 123306)
--- dwarf2out.c	(working copy)
*************** reference_to_unused (tree * tp, int * wa
*** 10121,10132 ****
    if (DECL_P (*tp) && ! TREE_PUBLIC (*tp) && ! TREE_USED (*tp)
        && ! TREE_ASM_WRITTEN (*tp))
      return *tp;
!   else if (DECL_P (*tp) && TREE_CODE (*tp) != FUNCTION_DECL)
      {
        struct varpool_node *node = varpool_node (*tp);
        if (!node->needed)
  	return *tp;
      }
  
    return NULL_TREE;
  }
--- 10121,10143 ----
    if (DECL_P (*tp) && ! TREE_PUBLIC (*tp) && ! TREE_USED (*tp)
        && ! TREE_ASM_WRITTEN (*tp))
      return *tp;
!   else if (!flag_unit_at_a_time)
!     return NULL_TREE;
!   else if (!cgraph_global_info_ready
! 	   && (TREE_CODE (*tp) == VAR_DECL || TREE_CODE (*tp) == FUNCTION_DECL))
!     gcc_unreachable ();
!   else if (DECL_P (*tp) && TREE_CODE (*tp) == VAR_DECL)
      {
        struct varpool_node *node = varpool_node (*tp);
        if (!node->needed)
  	return *tp;
      }
+   else if (DECL_P (*tp) && TREE_CODE (*tp) == FUNCTION_DECL)
+     {
+       struct cgraph_node *node = cgraph_node (*tp);
+       if (!node->output)
+         return *tp;
+     }
  
    return NULL_TREE;
  }


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