[PATCH] Fix ICF with error/warning attribute (PR ipa/84628)

Richard Biener rguenther@suse.de
Fri Mar 2 07:58:00 GMT 2018


On Fri, 2 Mar 2018, Jakub Jelinek wrote:

> Hi!
> 
> If we need to use thunks for ICF to functions with warning or error
> attribute, their expansion will warn or error.  This patch just punts
> in those cases instead.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Looks ok but I wonder if marking the call in the thunk with no-warning
would work as well?

Richard.

> 2018-03-02  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR ipa/84628
> 	* ipa-icf.c (sem_function::merge): Don't create wrappers for
> 	functions with warning or error attributes.
> 
> 	* gcc.dg/pr84628.c: New test.
> 
> --- gcc/ipa-icf.c.jj	2018-01-04 12:37:25.365487352 +0100
> +++ gcc/ipa-icf.c	2018-03-01 11:48:54.023107823 +0100
> @@ -1213,6 +1213,15 @@ sem_function::merge (sem_item *alias_ite
>  	  if (dump_file)
>  	    fprintf (dump_file, "Wrappers are not created for noinline.\n");
>  	}
> +      /* Calls in the thunks would warn or error if we create a wrapper
> +	 for functions with warning or error attribute.  */
> +      else if (lookup_attribute ("warning", DECL_ATTRIBUTES (original->decl))
> +	       || lookup_attribute ("error", DECL_ATTRIBUTES (original->decl)))
> +	{
> +	  if (dump_file)
> +	    fprintf (dump_file, "Wrappers are not created for error/warning "
> +			        "attribute.\n");
> +	}
>        else
>          create_wrapper = true;
>  
> --- gcc/testsuite/gcc.dg/pr84628.c.jj	2018-03-01 11:30:39.121021498 +0100
> +++ gcc/testsuite/gcc.dg/pr84628.c	2018-03-01 11:28:41.383127588 +0100
> @@ -0,0 +1,8 @@
> +/* PR ipa/84628 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +int f0 (void);
> +__attribute__((error ("err"))) void f1 (void) { f0 (); f0 (); }
> +__attribute__((error ("err"))) void f2 (void) { f0 (); f0 (); }
> +/* { dg-bogus "declared with attribute error" "" { target *-*-* } 0 } */
> 
> 	Jakub
> 
> 

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



More information about the Gcc-patches mailing list