diff mbox series

GCC 6 backports

Message ID f989799d-44cc-de5e-6a6d-b8b8ef4da576@suse.cz
State New
Headers show
Series GCC 6 backports | expand

Commit Message

Martin Liška March 7, 2018, 9:41 a.m. UTC
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

Comments

Martin Liška March 8, 2018, 8:51 a.m. UTC | #1
On 03/07/2018 10:41 AM, Martin Liška wrote:
> 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
> 

Hi.

There are 4 more patches I've tested.

Martin
H.J. Lu March 10, 2018, 6:28 p.m. UTC | #2
On Wed, Mar 7, 2018 at 1:41 AM, Martin Liška <mliska@suse.cz> wrote:
> 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

I am going to backport:

https://gcc.gnu.org/ml/gcc-cvs/2018-01/msg00211.html

to GCC 6 branch to fix:

FAIL: g++.dg/ipa/pr82352.C  -std=gnu++11 (test for excess errors)
FAIL: g++.dg/ipa/pr82352.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/ipa/pr82352.C  -std=gnu++98 (test for excess errors)
Martin Liška March 13, 2018, 12:26 p.m. UTC | #3
On 03/10/2018 07:28 PM, H.J. Lu wrote:
> On Wed, Mar 7, 2018 at 1:41 AM, Martin Liška <mliska@suse.cz> wrote:
>> 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
> 
> I am going to backport:

Thank you for the patch and for backport of the patch.

Martin

> 
> https://gcc.gnu.org/ml/gcc-cvs/2018-01/msg00211.html
> 
> to GCC 6 branch to fix:
> 
> FAIL: g++.dg/ipa/pr82352.C  -std=gnu++11 (test for excess errors)
> FAIL: g++.dg/ipa/pr82352.C  -std=gnu++14 (test for excess errors)
> FAIL: g++.dg/ipa/pr82352.C  -std=gnu++98 (test for excess errors)
>
Martin Liška April 25, 2018, 7:38 a.m. UTC | #4
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  <rguenther@suse.de>
	    Martin Liska  <mliska@suse.cz>

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

gcc/testsuite/ChangeLog:

2018-04-10  Jakub Jelinek  <jakub@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 ();
+}
Jan Hubicka April 25, 2018, 1:16 p.m. UTC | #5
> 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  <rguenther@suse.de>
> 	    Martin Liska  <mliska@suse.cz>
> 
> 	PR lto/85248
> 	* lto-symtab.c (lto_symtab_merge_p): Handle noreturn attribute.

Support for syntactic duplicates was new at that time and several
changes was made later. So enabling more of them may lead to troubles.
Did you test that this works for Firefox build?

Honza
Martin Liška May 18, 2018, 8:01 a.m. UTC | #6
On 04/25/2018 03:16 PM, Jan Hubicka wrote:
>> 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  <rguenther@suse.de>
>> 	    Martin Liska  <mliska@suse.cz>
>>
>> 	PR lto/85248
>> 	* lto-symtab.c (lto_symtab_merge_p): Handle noreturn attribute.
> 
> Support for syntactic duplicates was new at that time and several
> changes was made later. So enabling more of them may lead to troubles.
> Did you test that this works for Firefox build?

No, but I've just tested Libreoffice build w/ LTO and it's successfully built.

Martin

> 
> Honza
>
diff mbox series

Patch

From f447d7447bf9804c4673fbf19f6163dd9918f004 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 20 Feb 2018 10:04:13 +0000
Subject: [PATCH 15/15] Backport r257842

gcc/ChangeLog:

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

	PR c/84310
	PR target/79747
	* final.c (shorten_branches): Build align_tab array with one
	more element.
	* opts.c (finish_options): Add alignment option limit check.
	(MAX_CODE_ALIGN): Likewise.
	(MAX_CODE_ALIGN_VALUE): Likewise.
	* doc/invoke.texi: Document maximum allowed option value for
	all -falign-* options.

gcc/testsuite/ChangeLog:

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

	PR c/84310
	PR target/79747
	* gcc.target/i386/pr84310.c: New test.
	* gcc.target/i386/pr84310-2.c: Likewise.
---
 gcc/doc/invoke.texi                       |  4 ++++
 gcc/final.c                               |  4 ++--
 gcc/opts.c                                | 20 ++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/pr84310-2.c | 10 ++++++++++
 gcc/testsuite/gcc.target/i386/pr84310.c   |  8 ++++++++
 5 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr84310-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr84310.c

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index dbd019f2c79..df4f5bd17d8 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -7822,6 +7822,7 @@  Some assemblers only support this flag when @var{n} is a power of two;
 in that case, it is rounded up.
 
 If @var{n} is not specified or is zero, use a machine-dependent default.
+The maximum allowed @var{n} option value is 65536.
 
 Enabled at levels @option{-O2}, @option{-O3}.
 
@@ -7841,6 +7842,7 @@  are greater than this value, then their values are used instead.
 
 If @var{n} is not specified or is zero, use a machine-dependent default
 which is very likely to be @samp{1}, meaning no alignment.
+The maximum allowed @var{n} option value is 65536.
 
 Enabled at levels @option{-O2}, @option{-O3}.
 
@@ -7854,6 +7856,7 @@  operations.
 
 @option{-fno-align-loops} and @option{-falign-loops=1} are
 equivalent and mean that loops are not aligned.
+The maximum allowed @var{n} option value is 65536.
 
 If @var{n} is not specified or is zero, use a machine-dependent default.
 
@@ -7871,6 +7874,7 @@  need be executed.
 equivalent and mean that loops are not aligned.
 
 If @var{n} is not specified or is zero, use a machine-dependent default.
+The maximum allowed @var{n} option value is 65536.
 
 Enabled at levels @option{-O2}, @option{-O3}.
 
diff --git a/gcc/final.c b/gcc/final.c
index 55cf509611f..c07764e02e2 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -901,7 +901,7 @@  shorten_branches (rtx_insn *first)
   char *varying_length;
   rtx body;
   int uid;
-  rtx align_tab[MAX_CODE_ALIGN];
+  rtx align_tab[MAX_CODE_ALIGN + 1];
 
   /* Compute maximum UID and allocate label_align / uid_shuid.  */
   max_uid = get_max_uid ();
@@ -1010,7 +1010,7 @@  shorten_branches (rtx_insn *first)
      alignment of n.  */
   uid_align = XCNEWVEC (rtx, max_uid);
 
-  for (i = MAX_CODE_ALIGN; --i >= 0;)
+  for (i = MAX_CODE_ALIGN + 1; --i >= 0;)
     align_tab[i] = NULL_RTX;
   seq = get_last_insn ();
   for (; seq; seq = PREV_INSN (seq))
diff --git a/gcc/opts.c b/gcc/opts.c
index 8f9862db57c..1467782bc3a 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -972,6 +972,26 @@  finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
       opts->x_flag_aggressive_loop_optimizations = 0;
       opts->x_flag_strict_overflow = 0;
     }
+
+  /* Comes from final.c -- no real reason to change it.  */
+#define MAX_CODE_ALIGN 16
+#define MAX_CODE_ALIGN_VALUE (1 << MAX_CODE_ALIGN)
+
+  if (opts->x_align_loops > MAX_CODE_ALIGN_VALUE)
+    error_at (loc, "-falign-loops=%d is not between 0 and %d",
+	      opts->x_align_loops, MAX_CODE_ALIGN_VALUE);
+
+  if (opts->x_align_jumps > MAX_CODE_ALIGN_VALUE)
+    error_at (loc, "-falign-jumps=%d is not between 0 and %d",
+	      opts->x_align_jumps, MAX_CODE_ALIGN_VALUE);
+
+  if (opts->x_align_functions > MAX_CODE_ALIGN_VALUE)
+    error_at (loc, "-falign-functions=%d is not between 0 and %d",
+	      opts->x_align_functions, MAX_CODE_ALIGN_VALUE);
+
+  if (opts->x_align_labels > MAX_CODE_ALIGN_VALUE)
+    error_at (loc, "-falign-labels=%d is not between 0 and %d",
+	      opts->x_align_labels, MAX_CODE_ALIGN_VALUE);
 }
 
 #define LEFT_COLUMN	27
diff --git a/gcc/testsuite/gcc.target/i386/pr84310-2.c b/gcc/testsuite/gcc.target/i386/pr84310-2.c
new file mode 100644
index 00000000000..dbf5db6ff87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr84310-2.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -malign-loops=16" } */
+/* { dg-warning "is obsolete" "" { target *-*-* } 0 } */
+
+void
+c (void)
+{
+  for (;;)
+    ;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr84310.c b/gcc/testsuite/gcc.target/i386/pr84310.c
new file mode 100644
index 00000000000..f82327e45f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr84310.c
@@ -0,0 +1,8 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -falign-functions=100000" } */
+/* { dg-error "is not between 0 and 65536" "" { target *-*-* } 0 } */
+
+void
+test_func (void)
+{
+}
-- 
2.16.2