Hi.

Sending GCC 6 branch backports.
Patches can bootstrap on ppc64le-redhat-linux and survives regression tests.
I'm going to install the patches.

Martin
>From e0d32b1f9e0dd0486e63040e1ab8f5d8e9f0fbd5 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 10 Apr 2018 07:24:59 +0000
Subject: [PATCH 1/4] Backport r259265

gcc/lto/ChangeLog:

2018-04-10  Richard Biener  <rguent...@suse.de>
	    Martin Liska  <mli...@suse.cz>

	PR lto/85248
	* lto-symtab.c (lto_symtab_merge_p): Handle noreturn attribute.

gcc/testsuite/ChangeLog:

2018-04-10  Jakub Jelinek  <ja...@redhat.com>

	PR lto/85248
	* gcc.dg/lto/pr85248_0.c: New test.
	* gcc.dg/lto/pr85248_1.c: New test.
---
 gcc/lto/lto-symtab.c                 | 16 +++++++++++++
 gcc/testsuite/gcc.dg/lto/pr85248_0.c | 45 ++++++++++++++++++++++++++++++++++++
 gcc/testsuite/gcc.dg/lto/pr85248_1.c |  9 ++++++++
 3 files changed, 70 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr85248_0.c
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr85248_1.c

diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index 6b3b785b674..b01288d7587 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -568,6 +568,9 @@ lto_symtab_merge_p (tree prevailing, tree decl)
 	  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));
@@ -595,6 +598,19 @@ lto_symtab_merge_p (tree prevailing, tree decl)
 		     "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)
+	  || (prev_attr
+	      && TREE_VALUE (TREE_VALUE (prev_attr))
+		 != TREE_VALUE (TREE_VALUE (attr))))
+	{
+          if (symtab->dump_file)
+	    fprintf (symtab->dump_file, "Not merging decls; "
+		     "noreturn attribute mismatch\n");
+	  return false;
+	}
     }
   return true;
 }
diff --git a/gcc/testsuite/gcc.dg/lto/pr85248_0.c b/gcc/testsuite/gcc.dg/lto/pr85248_0.c
new file mode 100644
index 00000000000..df61ac976a5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr85248_0.c
@@ -0,0 +1,45 @@
+/* PR lto/85248 */
+/* { dg-lto-do run } */
+/* { dg-lto-options { { -flto -O2 } } } */
+
+extern void test_alias (int s, int e) __asm__ (__USER_LABEL_PREFIX__ "test");
+extern void test_noreturn (int s, int e) __asm__ (__USER_LABEL_PREFIX__ "test")
+  __attribute__ ((__noreturn__));
+
+extern inline __attribute__ ((__always_inline__, __gnu_inline__)) void
+test (int s, int e)
+{
+  if (__builtin_constant_p (s) && s != 0)
+    test_noreturn (s, e);
+  else
+    test_alias (s, e);
+}
+
+int
+foo (void)
+{
+  static volatile int a;
+  return a;
+}
+
+static void
+bar (void)
+{
+  test (0, 1);
+  __builtin_exit (0);
+}
+
+static void
+baz ()
+{
+  test (1, 0);
+}
+
+int
+main ()
+{
+  if (foo ())
+    baz ();
+  bar ();
+  __builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr85248_1.c b/gcc/testsuite/gcc.dg/lto/pr85248_1.c
new file mode 100644
index 00000000000..5ce257181fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr85248_1.c
@@ -0,0 +1,9 @@
+/* { dg-options "-fno-lto" } */
+
+void
+test (int s, int e)
+{
+  asm volatile ("" : "+g" (s), "+g" (e) : : "memory");
+  if (s)
+    __builtin_abort ();
+}
-- 
2.16.3

>From 81ee9e20be3804e2c77974d79fd6229e2be355d9 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 10 Apr 2018 13:52:23 +0000
Subject: [PATCH 2/4] Backport r259274

gcc/lto/ChangeLog:

2018-04-10  Martin Liska  <mli...@suse.cz>

	PR lto/85248
	* lto-symtab.c (lto_symtab_merge_p): Do not check for
	TREE_VALUES of error attributes.
---
 gcc/lto/lto-symtab.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index b01288d7587..32a53b3348f 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -601,10 +601,7 @@ lto_symtab_merge_p (tree prevailing, tree decl)
 
       prev_attr = lookup_attribute ("noreturn", DECL_ATTRIBUTES (prevailing));
       attr = lookup_attribute ("noreturn", DECL_ATTRIBUTES (decl));
-      if ((prev_attr == NULL) != (attr == NULL)
-	  || (prev_attr
-	      && TREE_VALUE (TREE_VALUE (prev_attr))
-		 != TREE_VALUE (TREE_VALUE (attr))))
+      if ((prev_attr == NULL) != (attr == NULL))
 	{
           if (symtab->dump_file)
 	    fprintf (symtab->dump_file, "Not merging decls; "
-- 
2.16.3

>From eed3101fc80e261a3da029f0633087abcab06bf3 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 17 Apr 2018 05:41:40 +0000
Subject: [PATCH 3/4] Backport r259429

gcc/ChangeLog:

2018-04-17  Jan Hubicka  <j...@suse.cz>

	PR lto/85405
	* ipa-devirt.c (odr_types_equivalent_p): Handle bit fields.
---
 gcc/ipa-devirt.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 9853c4a499c..b4d2a94858f 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1576,8 +1576,15 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 				 "in another translation unit"));
 		    return false;
 		  }
-		gcc_assert (DECL_NONADDRESSABLE_P (f1)
-			    == DECL_NONADDRESSABLE_P (f2));
+		if (DECL_BIT_FIELD (f1) != DECL_BIT_FIELD (f2))
+		  {
+		    warn_odr (t1, t2, f1, f2, warn, warned,
+			      G_ ("one field is bitfield while other is not "));
+		    return false;
+		  }
+		else
+		  gcc_assert (DECL_NONADDRESSABLE_P (f1)
+			      == DECL_NONADDRESSABLE_P (f2));
 	      }
 
 	    /* If one aggregate has more fields than the other, they
-- 
2.16.3

>From 386d6dbbb4d85e34a56769e9c8064ad5304046a7 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 17 Apr 2018 08:28:21 +0000
Subject: [PATCH 4/4] Backport r259431

gcc/ChangeLog:

2018-04-17  Martin Liska  <mli...@suse.cz>

	PR lto/85405
	* ipa-devirt.c (odr_types_equivalent_p): Remove trailing
	in message, remote space in between '_G' and '('.
---
 gcc/ipa-devirt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index b4d2a94858f..0d06c3c237a 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1579,7 +1579,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 		if (DECL_BIT_FIELD (f1) != DECL_BIT_FIELD (f2))
 		  {
 		    warn_odr (t1, t2, f1, f2, warn, warned,
-			      G_ ("one field is bitfield while other is not "));
+			      G_("one field is bitfield while other is not"));
 		    return false;
 		  }
 		else
-- 
2.16.3

Reply via email to