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 PR29299


> 
> This fixes PR29299 where we failed to honor "used" attribute on function
> local statics.  Fixed by looking at DECL_PRESERVE_P in the varpool
> machinery.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> 
> Ok for mainline?

It would be nice if all the used/externally visible attributes was
handled in process_function_and_variable_attributes.  The
decide_is_variable_needed still contains non-unit-at-a-time path because
there is no place where to hook the processing, but I would like to
not make it handle attributes again.
I guess moving DECL_PRESERVE test to the function will work, but I
wonder why searching the attributes didn't marked function local static
as well?

I can try to debug it tomorrow unless you beat me ;)

Thanks,
Honza
> 
> Thanks,
> Richard.
> 
> --
> Richard Guenther <rguenther@suse.de>
> Novell / SUSE Labs
> 
> 
> 2006-10-09  Richard Guenther  <rguenther@suse.de>
> 
> 	PR middle-end/29299
> 	* cgraph.c (decide_is_variable_needed): Use DECL_PRESERVE_P to
> 	check for "used" attribute.  Do so for -funit-at-a-time, too.
> 
> 	* gcc.dg/pr29299.c: New testcase.
> 
> Index: cgraph.c
> ===================================================================
> *** cgraph.c	(revision 117569)
> --- cgraph.c	(working copy)
> *************** bool
> *** 939,948 ****
>   decide_is_variable_needed (struct cgraph_varpool_node *node, tree decl)
>   {
>     /* If the user told us it is used, then it must be so.  */
> !   if (node->externally_visible || node->force_output)
> !     return true;
> !   if (!flag_unit_at_a_time
> !       && lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
>       return true;
>   
>     /* ??? If the assembler name is set by hand, it is possible to assemble
> --- 939,947 ----
>   decide_is_variable_needed (struct cgraph_varpool_node *node, tree decl)
>   {
>     /* If the user told us it is used, then it must be so.  */
> !   if (node->externally_visible
> !       || node->force_output
> !       || DECL_PRESERVE_P (decl))
>       return true;
>   
>     /* ??? If the assembler name is set by hand, it is possible to assemble
> 
> /* { dg-do compile } */
> /* { dg-options "-O" } */
> 
> static int bof __attribute__((used));
> int foo()
> {
> 	static int barbarbarbar __attribute__((used));
> };
> 
> /* { dg-final { scan-assembler "barbarbarbar" } } */


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