From patchwork Wed Nov 15 18:28:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick O'Neill X-Patchwork-Id: 165545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2730427vqg; Wed, 15 Nov 2023 10:28:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEcRcc8JxLVHKai7K0ShPWlCP7oJq6ZUHcxP62C3qn5/56XE49zGAzZ+eOcrQWknOmT7ZXP X-Received: by 2002:a05:6214:509e:b0:675:6a83:8084 with SMTP id kk30-20020a056214509e00b006756a838084mr8079378qvb.14.1700072928877; Wed, 15 Nov 2023 10:28:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700072928; cv=pass; d=google.com; s=arc-20160816; b=Bv2PUZT6b1RVEWkG+B37rLk9x+/G6TWZ2tFbO6yxRSXa60ABQ3Rbibzqnh5TVAqwIr fwAcvYHNfRfnveEC2nO/9tZamubQzytCgmFQJVeXb2dOiJ/iEQsCc/vrpJcet+nTq1Z3 NKS5J10MFDw+Ycu2sY+6NWiWjNms3wO1GeBdLfFxZL/b/w/r8zTTb3zKvX/1woQ5M4zj yyhXxzJcleBD1MlOBl4Xt+UsA8pbVvdysF7iwUfHPm4ym3FTuYZRidvyvxanBu8QvAmm J7r2r7g1phbxm+EBfeVDGTp0w7dhXTSH+Y13/0CY/stJTUrBtk8+zIe/YAxwZ2rBgyee VPtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=LHCvZ1RLbi7djJKusvS50MXpp9Ut0vd39l7wfvTqzBM=; fh=xbH4Idpt98kZVLD/mDTPe7ZzMPYFZrmKz1DWN8uxFkc=; b=ph73fZW80em1ujXVtwH1rcGwye1k0dVGjwHNC8fUrxJk44LfC6LF2xScHMbS5lcuG5 6Y1Bx5EL4SqDHBXXGTyMt5RnVJo+eUUmdSAwjvwxxs68ll+XiXXGVL9z59uQiOtiHUMK k6Aj3/7+CZe0IlIoGRSatk3eSLCL3TMgdkAAl/Ctb+7qlQx067I/i1AlvWFww8kfrYew 22bwyyseWevb6hY8u+/EwdPJNIB0RAzlqYBCB62jQGdInFAKunohKNXdWdDJIzz00ELx vCioUHqeBA548ox6JCLVAx4TUKbI9dyL+6JfmWKsKXcj+GLtQ3Pc8n7trn+qA0NYKm2x PsyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=n5B1c5Yc; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v2-20020a0ccd82000000b0066143a7bf3fsi10203277qvm.225.2023.11.15.10.28.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 10:28:48 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=n5B1c5Yc; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FA233858C33 for ; Wed, 15 Nov 2023 18:28:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 7972A3858D32 for ; Wed, 15 Nov 2023 18:28:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7972A3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7972A3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700072906; cv=none; b=ZjoVcewESrfLob6XcWA0DGDbOr8CFl9RSe2pisovLEeVBDBeJGdjyHzEDqfZU5dDNGjGz0qAys2S1d2QAqMq/dSWYzJ1+4U5KZUIQ66ShdzSaQfmn5QjY9xn+POAvkn35OtfEG48/s2yCsIIgXB+a5etEZ6rEx6PRPXKV+TADOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700072906; c=relaxed/simple; bh=Rg+1eSHnY7hlh65hb5dYtMz2xmT+AhIAPiCKQ8RkvTQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xVoEbuqeeKNqANljRB0S+snA97uBQtC/fcpfYVLTgPD2OAF8XSuIffANKNmGCtpovZpC5xKLgK0juBvYhV5wFfH4h89jLkCDtmaMOAQdjlbFDCM/11zbBMFAJKwePws1+rTO7PYRcb62j1q78QeEoKUb2VkC4n7d9Ke6GWDC/rI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1cc3216b2a1so56441145ad.2 for ; Wed, 15 Nov 2023 10:28:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1700072902; x=1700677702; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LHCvZ1RLbi7djJKusvS50MXpp9Ut0vd39l7wfvTqzBM=; b=n5B1c5YcyQZC0/UoZS5PhTDTITqguLZ3aoL17/oMfmbn9hDNBHOSWh4iQCsRM2EXg9 hiB+tf+360nOcN6/ly5MOJSuCJFOx6ID8aPV+gQaf8ebGhMsC4z+zg7SGYGZhyfHiKQc tRe7ezwlPIQ3cwc/TddtCO44F7pZpKzkyW+gprjGzgP8CU74hoFLjoSn27WFkQNDtXL2 3j3S1KVtr5xax0wXKwR7LrHiX5LIIKKIB2p0gQSUPMzGI/9/fsUEz/RfCxz2GPv/1TQJ rrCXqe2D9kkfXO1vy4fPyWulphdOgJVuzzEpia4cxzRA9cvKG9kCqUvGr48KnMI6kZWz CVYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700072902; x=1700677702; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LHCvZ1RLbi7djJKusvS50MXpp9Ut0vd39l7wfvTqzBM=; b=Y2IU7YxN2SVct7kR6dqcs9Iwvrb3JbRQMci97rLZTaOEKmWmWauWv377H6kDN3+r6b sYe7XpdeQ2Js7Huxvs9GTcNcHfHk/yuC1gldYRZnx5Jis3fUsn1hTWw49hJaLnDCxJZS kJQmUaYGm0a+JsM5ZZ5UWfc7EIFsJC/lK4Hm1mSmzd6tcgecrO9r3JRMjQJAW3Wy04Kj Uk/ItHvni6GUC6VP42UdxlVgIhmCC8JUdePMEX9qBrSy+QsGFjwqOtlaMXpmuBzZN68c FXVUFpEGLbwXqx5m8rO1u0JMeEef6f6pS0qvmybb07WsczKb6ee68R/exRCP+ihoDUYH 5FVg== X-Gm-Message-State: AOJu0YwPdwG0zYDN0elS5h3JEq2AYJTErqHAi4paAYFojjWy9UeRNB1X xEJ1PWOvvVNnPbvpksdKXFdzn+NZecqakQiJ8KM= X-Received: by 2002:a17:903:24f:b0:1cc:449b:68ad with SMTP id j15-20020a170903024f00b001cc449b68admr6263273plh.44.1700072902487; Wed, 15 Nov 2023 10:28:22 -0800 (PST) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([12.44.203.122]) by smtp.gmail.com with ESMTPSA id 10-20020a170902c20a00b001b7f40a8959sm7664667pll.76.2023.11.15.10.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 10:28:21 -0800 (PST) From: Patrick O'Neill To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, jeffreyalaw@gmail.com, lehua.ding@rivai.ai, vineetg@rivosinc.com, gnu-toolchain@rivosinc.com, Patrick O'Neill Subject: [Committed] RISC-V: Fix ICE in non-canonical march parsing Date: Wed, 15 Nov 2023 10:28:15 -0800 Message-ID: <20231115182815.98917-1-patrick@rivosinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782591914318799047 X-GMAIL-MSGID: 1782655671529646979 Updated testcase names and committed. Thanks, Patrick --- Passing in a base extension in non-canonical order (i, e, g) causes GCC to ICE: xgcc: error: '-march=rv64ge': ISA string is not in canonical order. 'e' xgcc: internal compiler error: in add, at common/config/riscv/riscv-common.cc:671 ... This is fixed by skipping to the next extension when a non-canonical order is detected. gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_subset_list::parse_std_ext): Emit an error and skip to the next extension when a non-canonical ordering is detected. gcc/testsuite/ChangeLog: * gcc.target/riscv/arch-27.c: New test. * gcc.target/riscv/arch-28.c: New test. Signed-off-by: Patrick O'Neill --- Tested using rv64gc glibc on QEMU. --- gcc/common/config/riscv/riscv-common.cc | 17 +++++++++++++---- gcc/testsuite/gcc.target/riscv/arch-27.c | 7 +++++++ gcc/testsuite/gcc.target/riscv/arch-28.c | 7 +++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/arch-27.c create mode 100644 gcc/testsuite/gcc.target/riscv/arch-28.c diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 526dbb7603b..57fe856063e 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -1017,15 +1017,24 @@ riscv_subset_list::parse_std_ext (const char *p) std_ext = *p; /* Checking canonical order. */ + const char *prior_std_exts = std_exts; + while (*std_exts && std_ext != *std_exts) std_exts++; subset[0] = std_ext; if (std_ext != *std_exts && standard_extensions_p (subset)) - error_at (m_loc, - "%<-march=%s%>: ISA string is not in canonical order. " - "%<%c%>", - m_arch, *p); + { + error_at (m_loc, + "%<-march=%s%>: ISA string is not in canonical order. " + "%<%c%>", + m_arch, *p); + /* Extension ordering is invalid. Ignore this extension and keep + searching for other issues with remaining extensions. */ + std_exts = prior_std_exts; + p++; + continue; + } std_exts++; diff --git a/gcc/testsuite/gcc.target/riscv/arch-27.c b/gcc/testsuite/gcc.target/riscv/arch-27.c new file mode 100644 index 00000000000..70143b2156f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-27.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64ge -mabi=lp64d" } */ +int foo() +{ +} + +/* { dg-error "ISA string is not in canonical order. 'e'" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/riscv/arch-28.c b/gcc/testsuite/gcc.target/riscv/arch-28.c new file mode 100644 index 00000000000..934399a7b3a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-28.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64imaefcv -mabi=lp64d" } */ +int foo() +{ +} + +/* { dg-error "ISA string is not in canonical order. 'e'" "" { target *-*-* } 0 } */