public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-9639] i386: fix -march=amd crash
@ 2021-03-31 12:57 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2021-03-31 12:57 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f87a08caf42e45162e934c7120a677565149708a

commit r10-9639-gf87a08caf42e45162e934c7120a677565149708a
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Mar 24 15:58:03 2021 +0100

    i386: fix -march=amd crash
    
    It started with g:3e2ae3ee285a57455d5a23bd352a68c289130186 where
    new entry was added to processor_alias_table after generic node:
    
    +  {"amdfam19h", PROCESSOR_GENERIC, CPU_GENERIC, 0,
    +    M_CPU_TYPE (AMDFAM19H), P_NONE},
    
    and then the following is violated:
    
    /* NB: processor_alias_table stops at the "generic" entry.  */
    
    gcc/ChangeLog:
    
            PR target/99753
            * common/config/i386/i386-common.c (ARRAY_SIZE): Fix off-by-one
            error.
            * config/i386/i386-options.c (ix86_option_override_internal):
            Add run-time assert.
    
    gcc/testsuite/ChangeLog:
    
            PR target/99753
            * gcc.target/i386/pr99753.c: New test.
    
    (cherry picked from commit 4f00c4d40a539360938607561460904663c64cda)

Diff:
---
 gcc/common/config/i386/i386-common.c    | 2 +-
 gcc/config/i386/i386-options.c          | 3 +++
 gcc/testsuite/gcc.target/i386/pr99753.c | 5 +++++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c
index c2b2dee425e..fbf901db881 100644
--- a/gcc/common/config/i386/i386-common.c
+++ b/gcc/common/config/i386/i386-common.c
@@ -1863,7 +1863,7 @@ const pta processor_alias_table[] =
 };
 
 /* NB: processor_alias_table stops at the "generic" entry.  */
-int const pta_size = ARRAY_SIZE (processor_alias_table) - 6;
+unsigned int const pta_size = ARRAY_SIZE (processor_alias_table) - 7;
 unsigned int const num_arch_names = ARRAY_SIZE (processor_alias_table);
 
 /* Provide valid option values for -march and -mtune options.  */
diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index 9d0a66712c1..7bb644b67b4 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
@@ -1979,6 +1979,9 @@ ix86_option_override_internal (bool main_args_p,
     sorry ("%i-bit mode not compiled in",
 	   (opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) ? 64 : 32);
 
+  /* Last processor_alias_table must point to "generic" entry.  */
+  gcc_checking_assert (strcmp (processor_alias_table[pta_size - 1].name,
+			       "generic") == 0);
   for (i = 0; i < pta_size; i++)
     if (! strcmp (opts->x_ix86_arch_string, processor_alias_table[i].name))
       {
diff --git a/gcc/testsuite/gcc.target/i386/pr99753.c b/gcc/testsuite/gcc.target/i386/pr99753.c
new file mode 100644
index 00000000000..3def1fd7481
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr99753.c
@@ -0,0 +1,5 @@
+/* PR target/99753 */
+
+/* { dg-do compile } */
+/* { dg-options "-march=amd -m32" } */
+/* { dg-error "bad value .'amd'. for '-march=' switch"  "" { target *-*-* } 0 } */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-31 12:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 12:57 [gcc r10-9639] i386: fix -march=amd crash Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).