aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-02-20 11:04:13 +0100
committerMartin Liska <marxin@gcc.gnu.org>2018-02-20 10:04:13 +0000
commit5bbccd92506c4d260eca29d12fa30c75aaaee65b (patch)
treee8b704768df9cda9cb173b4b741372e31194f039 /gcc
parent0b2513e292a70d715affbe4a9b5af6672fcf99b3 (diff)
downloadgcc-5bbccd92506c4d260eca29d12fa30c75aaaee65b.zip
gcc-5bbccd92506c4d260eca29d12fa30c75aaaee65b.tar.gz
gcc-5bbccd92506c4d260eca29d12fa30c75aaaee65b.tar.bz2
Add limit for maximal alignment options (PR c/84310).
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-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: r257842
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/doc/invoke.texi4
-rw-r--r--gcc/final.c4
-rw-r--r--gcc/opts.c20
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.target/i386/pr84310-2.c10
-rw-r--r--gcc/testsuite/gcc.target/i386/pr84310.c8
7 files changed, 63 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 900f9d5..8764bb3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+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-02-19 Jakub Jelinek <jakub@redhat.com>
PR target/84146
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index a580794..973d77d 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -9159,6 +9159,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}.
@@ -9184,6 +9185,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}.
@@ -9197,6 +9199,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.
@@ -9214,6 +9217,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 78a7503..d2c3cd8 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -911,7 +911,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 ();
@@ -1016,7 +1016,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 f2795f9..33efcc0 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1039,6 +1039,26 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS) && opts->x_flag_tm)
sorry ("transactional memory is not supported with "
"%<-fsanitize=kernel-address%>");
+
+ /* 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/ChangeLog b/gcc/testsuite/ChangeLog
index 6a0c3bd..476374a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+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-02-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84446
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 0000000..e39a421
--- /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 0000000..f82327e
--- /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)
+{
+}