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: [PATCH] Fix missed debug PR77692


On Fri, 23 Sep 2016, Richard Biener wrote:

> 
> I am testing the following patch which re-instantiates behavior
> to emit DW_AT_const_value attributes for optimized out non-readonly
> global statics.  Those are readonly by means of the ability to
> remove them early (before any optimization such as removing stores
> to write-only global vars).  Before my change to make the
> late_global_decl debug hook not go via 
> add_location_or_const_value_attribute but only 
> tree_add_const_value_attribute_for_decl during the early debug phase
> the former function ran into rtl_for_decl_location doing
> 
>   /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time 
> constant,
>      and will have been substituted directly into all expressions that use 
> it.
>      C does not have such a concept, but C++ and other languages do.  */
>   if (!rtl && TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
>     rtl = rtl_for_decl_init (DECL_INITIAL (decl), TREE_TYPE (decl));
> 
> where obviously at this point of the compilation no DECL_RTL was
> created yet (the above code looks fishy to me -- 
> tree_add_const_value_attribute_for_decl checks for TREE_READONLY on
> the decl).
> 
> Anyway, bootstrapping and regtesting the following on 
> x86_64-unknown-linux-gnu (it makes gcc.dg/debug/dwarf2/const-2b.c PASS
> again).
> 
> Comments welcome.

Applied as r240483.

Richard.

> Richard.
> 
> 2016-09-23  Richard Biener  <rguenther@suse.de>
> 
> 	PR debug/77692
> 	* cgraphunit.c (analyze_functions): Before early removing
> 	global vars calls the late_global_decl debug handler mark
> 	the variable as readonly.
> 
> Index: gcc/cgraphunit.c
> ===================================================================
> --- gcc/cgraphunit.c	(revision 240388)
> +++ gcc/cgraphunit.c	(working copy)
> @@ -1194,8 +1194,15 @@ analyze_functions (bool first_time)
>  	     at looking at optimized away DECLs, since
>  	     late_global_decl will subsequently be called from the
>  	     contents of the now pruned symbol table.  */
> -	  if (!decl_function_context (node->decl))
> -	    (*debug_hooks->late_global_decl) (node->decl);
> +	  if (TREE_CODE (node->decl) == VAR_DECL
> +	      && !decl_function_context (node->decl))
> +	    {
> +	      /* We are reclaiming totally unreachable code and variables
> +	         so they effectively appear as readonly.  Show that to
> +		 the debug machinery.  */
> +	      TREE_READONLY (node->decl) = 1;
> +	      (*debug_hooks->late_global_decl) (node->decl);
> +	    }
>  
>  	  node->remove ();
>  	  continue;
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)


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