From patchwork Tue Jun 6 01:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Gao X-Patchwork-Id: 103528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3079777vqr; Mon, 5 Jun 2023 18:58:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7126fVZv7M294quHqeVToL5yX+jRH3ZW8Ws+71C6kiH8YZsveGmjJwIrQqtYc3RKZTryY0 X-Received: by 2002:aa7:da82:0:b0:514:9e3e:4e4e with SMTP id q2-20020aa7da82000000b005149e3e4e4emr668337eds.26.1686016694684; Mon, 05 Jun 2023 18:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686016694; cv=none; d=google.com; s=arc-20160816; b=tW56jSOXlpmagMw/iMeJZ0+HA7Vu3NM7foad+XjzhHgMlaBgq7wwLbC0+J9AsrLRxT w08gwCvvNNTWKgDlVCB5XVO00R4OPezEMBxyFkTvjdDSmcWfj7SJheePDBuVi4jeq03b trVCZGScfuC3Qm/4yDagNJ+ecnLNlXbnf2pDLmSNCUIXwzEhmv4NVUwa2g/UPUN/77rD sQe29ucgdEaykYsUGeFOf/rmQT6kYt/FoPuKxShEyUcTimRou3COa47ko2303NTGYuHI SFhDoTobxZ7nz/gEgpMa23ZZF+yZ/n5CRAxgLpri12e0bXj5tP7xX48VGcQIVX67fqo/ kqkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from:dmarc-filter:delivered-to; bh=Bkhb6AjfunRL41P/HdLiohLkJd5MLL2a6Zua2WYTZC8=; b=yTTNL52RYUpcd90E+MKIkkxN57wV4gu3SszhxUxbwLMhu9XkwSXnXut++roGIBHkHk XSyO62AmGEg1qSfSN2vqmMgmqlyn/FIAykhuAeUVA4eOUqGxpZ4U2X/m/FRdPWSwY34J oFPeZYp3PeXWqFS0oeiKZZhmOmDcKg2ZDmUxtYL4V6YMMQOfBcRn25LC6sEN8BTgSClS gx5PPTcCBRduMoshxPc18bQlPcdo0bkpIOGphdSf52sJ5H97//w6HvJntrm5PnWDL057 LH8VXuucQi2jf26wUx6jzt93Ehm0AsjHYXQe1BfVF2iFRn3+BKLJcdG8D9d0/fnit/+E jmOg== ARC-Authentication-Results: i=1; mx.google.com; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u2-20020aa7d542000000b0050d82f96859si6004054edr.145.2023.06.05.18.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 18:58:14 -0700 (PDT) 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; 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 D4A8F38582A3 for ; Tue, 6 Jun 2023 01:58:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [52.237.72.81]) by sourceware.org (Postfix) with ESMTP id F4001385841A for ; Tue, 6 Jun 2023 01:57:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F4001385841A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eswincomputing.com Received: from localhost.localdomain (unknown [10.12.130.31]) by app2 (Coremail) with SMTP id EggMCgBHjpSUkn5kTSwiAA--.2725S4; Tue, 06 Jun 2023 09:57:41 +0800 (CST) From: Fei Gao To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, jeffreyalaw@gmail.com, Fei Gao Subject: [PATCH] [RISC-V] correct machine mode in save-restore cfi RTL. Date: Tue, 6 Jun 2023 01:57:23 +0000 Message-Id: <20230606015723.12297-1-gaofei@eswincomputing.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: EggMCgBHjpSUkn5kTSwiAA--.2725S4 X-Coremail-Antispam: 1UD129KBjvJXoW7ur4DZF1rJrWUAr1rXFy7Jrb_yoW8KryUpF Z5KF4Sy3yFvFZrGFs3KFyxGa1ftwsYgry5u3s7Zw18Aw4kJrWDJ3ZIkF43XrWUGF4xWrs3 Cr15uF1YyF45W3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk214x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK6svPMxAI w28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr 4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxG rwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8Jw CI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2 z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfUoOJ5UUUUU X-CM-SenderInfo: xjdrwv3l6h245lqf0zpsxwx03jof0z/ X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767916641230909587?= X-GMAIL-MSGID: =?utf-8?q?1767916641230909587?= gcc/ChangeLog: * config/riscv/riscv.cc (riscv_adjust_libcall_cfi_prologue): use Pmode for cfi reg/mem machmode (riscv_adjust_libcall_cfi_epilogue): use Pmode for cfi reg machmode gcc/testsuite/ChangeLog: * gcc.target/riscv/save-restore-cfi-2.c: New test to check machmode for cfi reg/mem. --- gcc/config/riscv/riscv.cc | 6 +++--- .../gcc.target/riscv/save-restore-cfi-2.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/save-restore-cfi-2.c diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index caa7858b864..9eafd281260 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -5370,8 +5370,8 @@ riscv_adjust_libcall_cfi_prologue () else offset = saved_size - ((regno - S2_REGNUM + 4) * UNITS_PER_WORD); - reg = gen_rtx_REG (SImode, regno); - mem = gen_frame_mem (SImode, plus_constant (Pmode, + reg = gen_rtx_REG (Pmode, regno); + mem = gen_frame_mem (Pmode, plus_constant (Pmode, stack_pointer_rtx, offset)); @@ -5510,7 +5510,7 @@ riscv_adjust_libcall_cfi_epilogue () for (int regno = GP_REG_FIRST; regno <= GP_REG_LAST; regno++) if (BITSET_P (cfun->machine->frame.mask, regno - GP_REG_FIRST)) { - reg = gen_rtx_REG (SImode, regno); + reg = gen_rtx_REG (Pmode, regno); dwarf = alloc_reg_note (REG_CFA_RESTORE, reg, dwarf); } diff --git a/gcc/testsuite/gcc.target/riscv/save-restore-cfi-2.c b/gcc/testsuite/gcc.target/riscv/save-restore-cfi-2.c new file mode 100644 index 00000000000..44d805b4de8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/save-restore-cfi-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-rtl-pro_and_epilogue -O2 -march=rv64gc -mabi=lp64d -msave-restore -mcmodel=medany" } */ +/* { dg-skip-if "" { *-*-* } {"-Os" "-O1" "-O0" "-Og" "-O3" "-Oz" "-flto"} } */ +/* { dg-final { scan-rtl-dump {expr_list:REG_CFA_OFFSET \(set \(mem/c:DI} "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump {expr_list:REG_CFA_RESTORE \(reg:DI 8 s0\)} "pro_and_epilogue" } } */ + +char my_getchar(); +float getf(); + +int foo() +{ + int s0 = my_getchar(); + float f0 = getf(); + int b = my_getchar(); + return f0 + s0 + b; +}