This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix ICF with error/warning attribute (PR ipa/84628)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>, Martin Liška <mliska at suse dot cz>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Mar 2018 00:09:09 +0100
- Subject: [PATCH] Fix ICF with error/warning attribute (PR ipa/84628)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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?
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