]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r257842
authorMartin Liska <mliska@suse.cz>
Wed, 7 Mar 2018 09:49:47 +0000 (10:49 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 7 Mar 2018 09:49:47 +0000 (09:49 +0000)
2018-03-07  Martin Liska  <mliska@suse.cz>

Backport from mainline
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.
2018-03-07  Martin Liska  <mliska@suse.cz>

Backport from mainline
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.

From-SVN: r258332

gcc/ChangeLog
gcc/doc/invoke.texi
gcc/final.c
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr84310-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr84310.c [new file with mode: 0644]

index a7526091cb8c1801607d42f49c58dcfe3647457c..f2d0637cce6a656ea6f96abc17742dcfddd9eae5 100644 (file)
@@ -1,3 +1,18 @@
+2018-03-07  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       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.
+
 2018-03-07  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index dbd019f2c79ae0cfd555af64ae6b869376060fd0..df4f5bd17d81b4ecd3190a3a3b8e08c859393f76 100644 (file)
@@ -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}.
 
index 55cf509611f7bc61246c63a6e997bd7402dd8428..c07764e02e235b9de486f6f35c77ca85a4d7b992 100644 (file)
@@ -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))
index 8f9862db57c24b1a07bb780014a67152b7489f22..1467782bc3a312a63d3cab33924bb2f93154278c 100644 (file)
@@ -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
index 2d75729f2961acd942938e5f38f9636fcab4001c..8421e5002e01cab27009561d157fbfee4927f30a 100644 (file)
@@ -1,3 +1,13 @@
+2018-03-07  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       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.
+
 2018-03-07  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.target/i386/pr84310-2.c b/gcc/testsuite/gcc.target/i386/pr84310-2.c
new file mode 100644 (file)
index 0000000..dbf5db6
--- /dev/null
@@ -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 (file)
index 0000000..f82327e
--- /dev/null
@@ -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)
+{
+}