From patchwork Wed Aug 9 03:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 133035 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2531555vqr; Tue, 8 Aug 2023 20:06:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPNfUWnhLZyyJeX/EF7mSWq7+BLhmn3jTPz8J9cgsAiYuj0HF1AEH5shByHV17NKqpjMVQ X-Received: by 2002:a17:906:328f:b0:99b:f3d1:7718 with SMTP id 15-20020a170906328f00b0099bf3d17718mr1085151ejw.28.1691550363691; Tue, 08 Aug 2023 20:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691550363; cv=none; d=google.com; s=arc-20160816; b=qvBoggyhBfi5T3ntjHNhrqei/pUOYalkAVH5SRTWvxPzR3w2qngwlgctPQPztSNH2o kaAAH3oeRegd/MBTqI7QhWHfCu2MOXGjsiPbhmkRgiX9PboR7rtwo4jtq6EMlEdAct6X PVhDt92XPwZYNFWcvbAgNcxrhGzDUOqituq7NNCSN57HVDn8M4/11bGI31q0Dn2LyEpt qu9lPRC80ZWcF/6PNNDeS/kYenX+au1DPb1Po4nFbJjmcb9HLR4PU5N7p0I6zWWwWaNC 27R3iVZGSteIXkKeqb0VSgiwdfAukswJB3klInVYQwhD/lrOpotF64G1k7c+BoeHE+Ot eKQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=2QZc37QYFpyj4bAzUwnvjWqgEaf8ZJETXJ4SPCwMeuQ=; fh=e3qckc+Yoo2IRFrgNi2OpdfwrygbVRbDMAYzNjKeDgQ=; b=YBc7rvcotG+ZqTcIJdGhiaC+yVqnqCqC8JTIZyPqKe53Lt0wXCPJKCfPcV9T5WZpzo XJxEf0AOIV0G9Q1NQ9fNwxZXUpxrvSS55kPIRQTqJercNSMKRm67T1QuNltW3iXGM0VW bSkU3FRNzL6J/K+DBXtmg8BTRrsYlY8uEK6D6BBVfaz9nc6Bigb80l1GFaB+fyi3oK9P E1NFBu3I7x1YipnZePlikdoqZgy9yWhlo3GgKrEdhQTWK3A9nCNhdvYZhDju4jA9Xm03 Zw9bPgWS23c+YkIPmEca9hu0RrahNT2piTEQAJpUbeZH0sLomRnxQSAe/IdIVC8cQ98F SdXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QCzVu4UI; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g3-20020a170906198300b0099bcd1d96acsi8682185ejd.9.2023.08.08.20.06.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 20:06:03 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=QCzVu4UI; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DE7A3858D20 for ; Wed, 9 Aug 2023 03:06:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DE7A3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691550362; bh=2QZc37QYFpyj4bAzUwnvjWqgEaf8ZJETXJ4SPCwMeuQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=QCzVu4UIGoMw2umdoAnpwyKdw9nAXiLE7D1hQdSLC5QzEaYy/4UPr7LV5Utj4VU0+ XgoLp9Y44Xu8hKuBGGAjDEpzOxRfbAvVzNsdpuGpjn1dJcgkcelgmS5vtM6PFV8Jq5 qmX5uej2Tu+0ySTDCvogUFIihvPLJIBk3jca8jbk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id ABAAD3858D20 for ; Wed, 9 Aug 2023 03:05:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ABAAD3858D20 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="361129615" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="361129615" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2023 20:05:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="978202984" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="978202984" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga006.fm.intel.com with ESMTP; 08 Aug 2023 20:05:13 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 0B65C1007BC6; Wed, 9 Aug 2023 11:05:13 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, pan2.li@intel.com, yanzhang.wang@intel.com, jeffreyalaw@gmail.com Subject: [PATCH v3] Mode-Switching: Fix SET_SRC ICE when CLOBBER insn Date: Wed, 9 Aug 2023 11:05:11 +0800 Message-Id: <20230809030511.857619-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807122247.1881775-1-pan2.li@intel.com> References: <20230807122247.1881775-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pan Li via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: pan2.li@intel.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773719114467972235 X-GMAIL-MSGID: 1773719114467972235 From: Pan Li In same cases, like gcc/testsuite/gcc.dg/pr78148.c in RISC-V, there will be only 1 operand when SET_SRC in create_pre_exit. For example as below. (insn 13 9 14 2 (clobber (reg/i:TI 10 a0)) "gcc/testsuite/gcc.dg/pr78148.c":24:1 -1 (expr_list:REG_UNUSED (reg/i:TI 10 a0) (nil))) Unfortunately, SET_SRC requires at least 2 operands and then Segment Fault here. For SH4 part result in Segment Fault, it looks like only valid when the return_copy_pat is load or something like that. Thus, this patch try to fix it by ingnoring the CLOBBER insn for SH4. Signed-off-by: Pan Li gcc/ChangeLog: * mode-switching.cc (create_pre_exit): Add CLOBBER check. gcc/testsuite/ChangeLog: * gcc.target/riscv/mode-switch-ice-1.c: New test. --- gcc/mode-switching.cc | 2 +- .../gcc.target/riscv/mode-switch-ice-1.c | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c diff --git a/gcc/mode-switching.cc b/gcc/mode-switching.cc index 64ae2bc29c3..b034cf7d437 100644 --- a/gcc/mode-switching.cc +++ b/gcc/mode-switching.cc @@ -392,7 +392,7 @@ create_pre_exit (int n_entities, int *entity_map, const int *num_modes) && mode != targetm.mode_switching.exit (e)) break; } - if (j >= 0) + if (j >= 0 && GET_CODE (return_copy_pat) != CLOBBER) { /* __builtin_return emits a sequence of loads to all return registers. One of them might require diff --git a/gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c b/gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c new file mode 100644 index 00000000000..1b34a471904 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct A { char e, f; }; + +struct B +{ + int g; + struct A h[4]; +}; + +extern void bar (int, int); + +struct B foo (void) +{ + bar (2, 1); +} + +void baz () +{ + foo (); +}