Use flags_from_decl_or_type in lto_symtab_merge_p (PR ipa/85248).

Message ID b10fbaa4-5559-5e1f-9c8d-98d687b25c57@suse.cz
State New
Headers show
Series
  • Use flags_from_decl_or_type in lto_symtab_merge_p (PR ipa/85248).
Related show

Commit Message

Martin Liška June 8, 2018, 11:10 a.m.
Hi.

Second follow-up patch uses flags_from_decl_or_type in LTO merging
of declarations. Hope it's more cleaner approach.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Martin

Comments

Richard Biener June 13, 2018, 11:21 a.m. | #1
On Fri, Jun 8, 2018 at 1:10 PM Martin Liška <mliska@suse.cz> wrote:
>

> Hi.

>

> Second follow-up patch uses flags_from_decl_or_type in LTO merging

> of declarations. Hope it's more cleaner approach.

>

> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

>

> Ready to be installed?


That doesn't handle the "error" attribute case anymore?

We also have attribute_list_equal / attribute_list_contained that could be
used here?

Richard.

> Martin
Martin Liška June 20, 2018, 8:03 a.m. | #2
On 06/13/2018 01:21 PM, Richard Biener wrote:
> On Fri, Jun 8, 2018 at 1:10 PM Martin Liška <mliska@suse.cz> wrote:

>>

>> Hi.

>>

>> Second follow-up patch uses flags_from_decl_or_type in LTO merging

>> of declarations. Hope it's more cleaner approach.

>>

>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

>>

>> Ready to be installed?

> 

> That doesn't handle the "error" attribute case anymore?

> 

> We also have attribute_list_equal / attribute_list_contained that could be

> used here?


You are right, it can't work. Thus I would erase the FIXME comment.

Is it fine?
Martin

> 

> Richard.

> 

>> Martin
From a9c0185ec343aa9064f5166645651e603a2b8538 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>

Date: Wed, 20 Jun 2018 10:01:48 +0200
Subject: [PATCH] Remove not longer valid FIXME comment.

gcc/lto/ChangeLog:

2018-06-20  Martin Liska  <mliska@suse.cz>

	* lto-symtab.c (lto_symtab_merge_p): Remove not valid
        FIXME comment.
---
 gcc/lto/lto-symtab.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index a40ba1f32ef..0d603c0281f 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -564,8 +564,6 @@ lto_symtab_merge_p (tree prevailing, tree decl)
 	}
     }
 
-  /* FIXME: after MPX is removed, use flags_from_decl_or_type
-     function instead.  PR lto/85248.  */
   if (DECL_ATTRIBUTES (prevailing) != DECL_ATTRIBUTES (decl))
     {
       tree prev_attr = lookup_attribute ("error", DECL_ATTRIBUTES (prevailing));
-- 
2.17.1
Richard Biener June 20, 2018, 8:34 a.m. | #3
On Wed, Jun 20, 2018 at 10:03 AM Martin Liška <mliska@suse.cz> wrote:
>

> On 06/13/2018 01:21 PM, Richard Biener wrote:

> > On Fri, Jun 8, 2018 at 1:10 PM Martin Liška <mliska@suse.cz> wrote:

> >>

> >> Hi.

> >>

> >> Second follow-up patch uses flags_from_decl_or_type in LTO merging

> >> of declarations. Hope it's more cleaner approach.

> >>

> >> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

> >>

> >> Ready to be installed?

> >

> > That doesn't handle the "error" attribute case anymore?

> >

> > We also have attribute_list_equal / attribute_list_contained that could be

> > used here?

>

> You are right, it can't work. Thus I would erase the FIXME comment.

>

> Is it fine?


Ok.

Richard.

> Martin

>

> >

> > Richard.

> >

> >> Martin

>

Patch

From 17d598f028c723cb11e8a9f786e3026c0cfca4aa Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 8 Jun 2018 10:14:47 +0200
Subject: [PATCH] Use flags_from_decl_or_type in lto_symtab_merge_p (PR
 ipa/85248).

gcc/lto/ChangeLog:

2018-06-08  Martin Liska  <mliska@suse.cz>

        PR ipa/85248
	* lto-symtab.c (lto_symtab_merge_p): Use
        flags_from_decl_or_type.
---
 gcc/lto/lto-symtab.c | 50 +++++++++++++-------------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index b1df9bb77d1..2259358ea5f 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -34,6 +34,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "lto-symtab.h"
 #include "stringpool.h"
 #include "attribs.h"
+#include "calls.h"
 
 /* Replace the cgraph node NODE with PREVAILING_NODE in the cgraph, merging
    all edges and removing the old node.  */
@@ -547,7 +548,7 @@  lto_symtab_merge_p (tree prevailing, tree decl)
     {
       if (DECL_BUILT_IN (prevailing) != DECL_BUILT_IN (decl))
 	{
-          if (symtab->dump_file)
+	  if (symtab->dump_file)
 	    fprintf (symtab->dump_file, "Not merging decls; "
 		     "DECL_BUILT_IN mismatch\n");
 	  return false;
@@ -561,44 +562,23 @@  lto_symtab_merge_p (tree prevailing, tree decl)
 		     "DECL_BUILT_IN_CLASS or CODE mismatch\n");
 	  return false;
 	}
-    }
 
-  /* FIXME: after MPX is removed, use flags_from_decl_or_type
-     function instead.  PR lto/85248.  */
-  if (DECL_ATTRIBUTES (prevailing) != DECL_ATTRIBUTES (decl))
-    {
-      tree prev_attr = lookup_attribute ("error", DECL_ATTRIBUTES (prevailing));
-      tree attr = lookup_attribute ("error", DECL_ATTRIBUTES (decl));
-      if ((prev_attr == NULL) != (attr == NULL)
-	  || (prev_attr && !attribute_value_equal (prev_attr, attr)))
+      if (DECL_ATTRIBUTES (prevailing) != DECL_ATTRIBUTES (decl))
 	{
-          if (symtab->dump_file)
-	    fprintf (symtab->dump_file, "Not merging decls; "
-		     "error attribute mismatch\n");
-	  return false;
-	}
-
-      prev_attr = lookup_attribute ("warning", DECL_ATTRIBUTES (prevailing));
-      attr = lookup_attribute ("warning", DECL_ATTRIBUTES (decl));
-      if ((prev_attr == NULL) != (attr == NULL)
-	  || (prev_attr && !attribute_value_equal (prev_attr, attr)))
-	{
-          if (symtab->dump_file)
-	    fprintf (symtab->dump_file, "Not merging decls; "
-		     "warning attribute mismatch\n");
-	  return false;
-	}
-
-      prev_attr = lookup_attribute ("noreturn", DECL_ATTRIBUTES (prevailing));
-      attr = lookup_attribute ("noreturn", DECL_ATTRIBUTES (decl));
-      if ((prev_attr == NULL) != (attr == NULL))
-	{
-          if (symtab->dump_file)
-	    fprintf (symtab->dump_file, "Not merging decls; "
-		     "noreturn attribute mismatch\n");
-	  return false;
+	  int prev_decl_attrs
+	    = flags_from_decl_or_type (prevailing);
+	  int decl_attrs
+	    = flags_from_decl_or_type (decl);
+	  if (prev_decl_attrs != decl_attrs)
+	    {
+	      if (symtab->dump_file)
+		fprintf (symtab->dump_file, "Not merging decls; "
+			 "DECL_ATTRIBUTES mismatch\n");
+	      return false;
+	    }
 	}
     }
+
   return true;
 }
 
-- 
2.17.0