From patchwork Wed Nov 15 01:33:17 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: 165142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2323041rwb; Tue, 14 Nov 2023 17:35:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCa4wAuqRTnkrJ4jUY3Bi4LHVg6fbbbyKjrcuYCX3YDQ2gRX6m3OU4BvSmq0QgzayeuFvH X-Received: by 2002:ac8:5888:0:b0:418:597:b71d with SMTP id t8-20020ac85888000000b004180597b71dmr5351813qta.4.1700012125260; Tue, 14 Nov 2023 17:35:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700012125; cv=pass; d=google.com; s=arc-20160816; b=BYWGKulNqnlMfb9LhezDZmDLdnm6JhjbpDUgu7nUcGbJdgHC3LOE1qxM8tOvTHEXNP q6qaT4nW2dm7OSrOT5PGEoEE88hmSj8DKq2tzw9Cfy5HoMZul9uI8hq/NzWDFMTztTp9 6cxlq2QOiCG7f0PO2gUO2dQS/ZkYbX9txKzAhnTWE0lRaI3mBtonWPgHcg2SiLo7viFY HRy6fbmg9BqPMgaoWdIOhkgLmE65MDxF9U9fuL75FcPFqQhgyxZKlvFIeO6Mm/iI6Zi3 b97C1kMR2Q5ql2vYx8+r7dyXd9VRD7yooxV0h+mLIXoyRiKQuCtw/UeG9C687nbXResJ FOPg== 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:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=9umRrpqN9sb34OHuZ7KMe2FNnrtxITH1K0vm2BcXdoA=; fh=BTfv18g9/QUkfFwIL8I/l9bWLaKunGLThC0bj/uENoM=; b=wY88FnxH6/g4PvYtl1L1N4XXLsvmUwzFj9/FgAIS6qV61cm4s2YM9/DPDYrz6q6rrd YHfc84fjU9wl/pPk8tPTttxpE0vGlyJlWpMcuLuZ1uO6XDELi5RwpurFTYJe0JrsQLPP aECQtZCoi42IulC6GKWkA+pPlN+mOd6b16Jylach2Hq4rM7K2TVj0c771Y1GiRJcRoe1 43BIARrqTbbuQPQoWcbZdbW8kKRox5/T/LXRVUS7g6UeBb082p4KxrHZbqpzYkG3oohA D7w/hWhHYj0tU5TcdbmCOanoVPbzP/obZX3gMss9FHYBvetPKNWoGG12V0JLlWjwX5z0 9PFQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=m2griQJh; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r3-20020ac85c83000000b00417ba0580b1si7913206qta.626.2023.11.14.17.35.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 17:35:25 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=m2griQJh; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 0441F3858420 for ; Wed, 15 Nov 2023 01:35:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id C67473858C41 for ; Wed, 15 Nov 2023 01:34:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C67473858C41 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 C67473858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700012102; cv=none; b=CFslyPSoqHyiE42Mh976m5SXCts+df9mOJYbZ3c8enj1ptfChilq8u3LbEft8EvtN5kW45tlw730qPSIu5/fYUjxn2m21saawvA4bloPlY39KY38ji6BSove54FIRrZKQ7okFBR+XvjHGfYHFynNB030osClvGtj7gHV+Ro4xoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700012102; c=relaxed/simple; bh=NSa391TtKdkvXnHKkcA2UGAP/PgqHeu9yqhNiuhSqjo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sgw+1LkpQ4z+f65/qfRCfxzIzk8KCZuIic/OA5OTisdMpOxnkFb4QvjTzbCIhe9Wzz9QyBpqn5icFpAYhtfYaUY6sXq4jwrZxc/HwENe+MEjAZCgKNXOZudYHi93OeXT81ZlQDJ35M9coh+0whQ4tDxrCSx+gpGD8Hj8uoPIiKU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6bb4abb8100so5343098b3a.2 for ; Tue, 14 Nov 2023 17:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1700012098; x=1700616898; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9umRrpqN9sb34OHuZ7KMe2FNnrtxITH1K0vm2BcXdoA=; b=m2griQJhp9czfIoMJ5O9fn23eaYSE8K6nQWUzNNw7lIiodgCI/8ANvYRTsWrjScVlO 81bM3SXQ6NzJTkSbDtURJOo+9tVdXQKza6aivIXtC3fs12thYOlTjUhgeMl3mqfuC0Or 1KqM9yo+uq6ru+2VYz4LsxFx5B/uWhv7kjGE+tsqybmLFVnbIBV135lx3HZ2/DStAfq2 XP1xJYpWtnTIlsZeucBxyxP8AzQFmP8cuHCoP0TdDytlAkeNNFGmuubnRDZgPPLHTgsU voaOdxU1htK5PajEyDvzvUq03xZm9RHFM5gp055QfqzS44Zz+7+lHoxn6kzvN9En+g55 s+Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700012098; x=1700616898; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9umRrpqN9sb34OHuZ7KMe2FNnrtxITH1K0vm2BcXdoA=; b=afMBX0SeS5DNkV8Zi0uKsYoTpdEKxciwQQx4NojK6S6FflHNHIHOf9mWXn9U8lLMKE oDyXMrHbc+SmTFk9VgNOsCKLZ3Sde6HCUggWqcuVN8rQxaaozp1F+6WagJRg52xyaMk9 5maEMf+tw6LxFO/cb4E5RjFm9IhjZBQMUUy6mbCb55iRdhCtcbysKlcg+LLDxB18BU3r XywpKWGNW0W5QkURIEPq2fWfvOUCu9E7dwBM62mIWzco8EzEq9wqSOAG7LqW8EmXO1zz KBSBkmVIj1wwHuAP4zpxQ8CVoVvki1qNUxwoQmKHfnmqoXeMEUmzid1M1fDfiGS8zUjb uSJw== X-Gm-Message-State: AOJu0Yz1mCkPPXctY8w7el4Wa6HmuLHnXbH0vyTrKD/sG1U42ubgkJi4 w2mTs8lsW5K4jv0R8cWHflTa5hMVWY13ALq9t1I= X-Received: by 2002:a05:6a20:3d17:b0:154:4246:d63b with SMTP id y23-20020a056a203d1700b001544246d63bmr10458803pzi.25.1700012098362; Tue, 14 Nov 2023 17:34:58 -0800 (PST) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([12.44.203.122]) by smtp.gmail.com with ESMTPSA id z18-20020a170903019200b001bb97e51ab4sm6356479plg.98.2023.11.14.17.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 17:34:57 -0800 (PST) From: Patrick O'Neill To: gcc-patches@gcc.gnu.org Cc: jeffreyalaw@gmail.com, lehua.ding@rivai.ai, vineetg@rivosinc.com, gnu-toolchain@rivosinc.com, Patrick O'Neill Subject: [PATCH] RISC-V: Fix ICE in non-canonical march parsing Date: Tue, 14 Nov 2023 17:33:17 -0800 Message-ID: <20231115013317.88282-1-patrick@rivosinc.com> X-Mailer: git-send-email 2.42.0 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: 1782591914318799047 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-24.c | 7 +++++++ gcc/testsuite/gcc.target/riscv/arch-25.c | 7 +++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/arch-24.c create mode 100644 gcc/testsuite/gcc.target/riscv/arch-25.c diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 884d81c12aa..66aea71ea2c 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -964,15 +964,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-24.c b/gcc/testsuite/gcc.target/riscv/arch-24.c new file mode 100644 index 00000000000..70143b2156f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-24.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-25.c b/gcc/testsuite/gcc.target/riscv/arch-25.c new file mode 100644 index 00000000000..934399a7b3a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-25.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 } */