From patchwork Wed Mar 24 18:37:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1457997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F5H5x69fZz9sRN for ; Thu, 25 Mar 2021 05:37:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 63C173851C39; Wed, 24 Mar 2021 18:37:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 0BFB23857C50 for ; Wed, 24 Mar 2021 18:37:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0BFB23857C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DBEA4AB8A; Wed, 24 Mar 2021 18:37:11 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] i386: fix -march=amd crash To: gcc-patches@gcc.gnu.org Message-ID: Date: Wed, 24 Mar 2021 19:37:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shravan.Kumar@amd.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 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. */ Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin 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. --- 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(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr99753.c diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c index eea8af12f48..b89183b830e 100644 --- a/gcc/common/config/i386/i386-common.c +++ b/gcc/common/config/i386/i386-common.c @@ -2051,7 +2051,7 @@ const pta processor_alias_table[] = }; /* NB: processor_alias_table stops at the "generic" entry. */ -unsigned 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 b653527d266..88d5e717f26 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -2042,6 +2042,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 } */