From patchwork Thu Jan 5 13:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshinori Sato X-Patchwork-Id: 39524 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp290758wrt; Thu, 5 Jan 2023 05:06:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXuak4ut/rcrBy2S6SdfCVA/gE/afqlGswT0DKSqZQVDreh3C7sXQT+JdW/WCt/kcQZc81IQ X-Received: by 2002:a05:6402:b91:b0:487:1a83:a6a0 with SMTP id cf17-20020a0564020b9100b004871a83a6a0mr26796218edb.13.1672924003882; Thu, 05 Jan 2023 05:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672924003; cv=none; d=google.com; s=arc-20160816; b=wX4mL8hAU2c/pBsZ8d5qegTVzXKE/n3/TrsgoAGYAcXffsNF5PhySf0JsbmGJ0VfL6 wUAUbPwV/c/PYLTWOpCrkii17SeFVYl/lxLCZ3J4YozVuZzHbpd3Pi+fhNq/nsP5Lt2K q4C0BWFhP8j3WrXkjE5FCbuV4Rv6v+cpi5R51CpODpHnBsXb3c8tqGMDLLaqxJHwGXq3 ENAnHGbk1Deco1lN8WBo7hIGi8ugj/7hRYHp6zaBCeemlFjrcNsqVPoahPB6sqv+RbYd NJedOHh6oaRG89oVFFlWuLCy2bdWQhJ0aAbj/df4SExnG7vHOUBFm5zYvc4bTBy1JiNR bZlg== 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:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dmarc-filter :delivered-to; bh=LzPEKqI22cT2gDH/x18U7z8URJKy3rpShviEhffQ+j8=; b=X9ErWD7lr7LdoW0OBToFXfuKdFQsYUdkUGUqXN9ybCbuJCd9/1IBeyf1qNR72EicwQ 05Zxv+kZIVmln8m8+y1xC6vltGTp8Bd8CNAwJk/QyWB6+jTAupRHX3ilCRmvbWVBAJuG +rxnaHzYQb4sfkPXMdPNNMS+s3WmLAQPUE+AiXPLhT+gosodzFSbSxfqHrAYcbn9OyGL dt8Lwa/CqQ+AoA57EiNN52CvpDDNAIAC8Kt9A/apAMyLOk/KWsv+2Izyg5MMv55CRL0f zV8ig/W9tMNSA3GF9VXCG/CDj1oqwn/NTHYChQ5R5fCFsaCUGDJL1yZY5xg6ZQfY2Zqc Oslg== 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 w18-20020a056402269200b0045782fcb80asi35616971edd.225.2023.01.05.05.06.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 05:06:43 -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; 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 7ECC03858414 for ; Thu, 5 Jan 2023 13:06:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from hsmtpd-def.xspmail.jp (hsmtpd-def.xspmail.jp [202.238.198.239]) by sourceware.org (Postfix) with ESMTPS id 6650E3858D35 for ; Thu, 5 Jan 2023 13:06:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6650E3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=users.sourceforge.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=users.sourceforge.jp X-Country-Code: JP Received: from sakura.ysato.name (ik1-413-38519.vs.sakura.ne.jp [153.127.30.23]) by hsmtpd-out-2.asahinet.cluster.xspmail.jp (Halon) with ESMTPA id 17e153ca-f5dc-4923-bf95-fff711348504; Thu, 05 Jan 2023 22:06:07 +0900 (JST) Received: from SIOS1075.ysato.name (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by sakura.ysato.name (Postfix) with ESMTPSA id 046611C01F0; Thu, 5 Jan 2023 22:06:05 +0900 (JST) From: Yoshinori Sato To: gcc-patches@gcc.gnu.org Cc: Yoshinori Sato Subject: [PATCH] PR target/89828 Inernal compiler error on -fno-omit-frame-pointer Date: Thu, 5 Jan 2023 22:05:53 +0900 Message-Id: <20230105130553.3434596-1-ysato@users.sourceforge.jp> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, 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: , 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?1754187960784003081?= X-GMAIL-MSGID: =?utf-8?q?1754187960784003081?= The problem was caused by an erroneous note about creating a stack frame, which caused the cur_cfa reg to fail to assert with a value other than the frame pointer. This fix will generate notes that correctly update cur_cfa. gcc/config/rx/ * rx.cc (add_pop_cfi_notes): Release the frame pointer if it is used. (rx_expand_prologue): Redesigned stack pointer and frame pointer update process. Signed-off-by: Yoshinori Sato --- gcc/config/rx/rx.cc | 50 +++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/gcc/config/rx/rx.cc b/gcc/config/rx/rx.cc index 412a3a354b0..8c246d42cd8 100644 --- a/gcc/config/rx/rx.cc +++ b/gcc/config/rx/rx.cc @@ -1647,16 +1647,20 @@ mark_frame_related (rtx insn) static void add_pop_cfi_notes (rtx_insn *insn, unsigned int high, unsigned int low) { - rtx t = plus_constant (Pmode, stack_pointer_rtx, - (high - low + 1) * UNITS_PER_WORD); + rtx src = stack_pointer_rtx; + rtx t; + for (unsigned int i = low; i <= high; i++) + { + add_reg_note (insn, REG_CFA_RESTORE, gen_rtx_REG (word_mode, i)); + if (i == FRAME_POINTER_REGNUM) + src = frame_pointer_rtx; + } + t = plus_constant (Pmode, src, (high - low + 1) * UNITS_PER_WORD); t = gen_rtx_SET (stack_pointer_rtx, t); add_reg_note (insn, REG_CFA_ADJUST_CFA, t); RTX_FRAME_RELATED_P (insn) = 1; - for (unsigned int i = low; i <= high; i++) - add_reg_note (insn, REG_CFA_RESTORE, gen_rtx_REG (word_mode, i)); } - static bool ok_for_max_constant (HOST_WIDE_INT val) { @@ -1815,37 +1819,17 @@ rx_expand_prologue (void) } } - /* If needed, set up the frame pointer. */ - if (frame_pointer_needed) - gen_safe_add (frame_pointer_rtx, stack_pointer_rtx, - GEN_INT (- (HOST_WIDE_INT) frame_size), true); - - /* Allocate space for the outgoing args. - If the stack frame has not already been set up then handle this as well. */ - if (stack_size) + if (stack_size || frame_size) { - if (frame_size) - { - if (frame_pointer_needed) - gen_safe_add (stack_pointer_rtx, frame_pointer_rtx, - GEN_INT (- (HOST_WIDE_INT) stack_size), true); - else - gen_safe_add (stack_pointer_rtx, stack_pointer_rtx, - GEN_INT (- (HOST_WIDE_INT) (frame_size + stack_size)), - true); - } - else - gen_safe_add (stack_pointer_rtx, stack_pointer_rtx, - GEN_INT (- (HOST_WIDE_INT) stack_size), true); + gen_safe_add (stack_pointer_rtx, stack_pointer_rtx, + GEN_INT (- (HOST_WIDE_INT) (stack_size + frame_size)), + true); } - else if (frame_size) + if (frame_pointer_needed) { - if (! frame_pointer_needed) - gen_safe_add (stack_pointer_rtx, stack_pointer_rtx, - GEN_INT (- (HOST_WIDE_INT) frame_size), true); - else - gen_safe_add (stack_pointer_rtx, frame_pointer_rtx, NULL_RTX, - false /* False because the epilogue will use the FP not the SP. */); + gen_safe_add (frame_pointer_rtx, stack_pointer_rtx, + GEN_INT ((HOST_WIDE_INT) stack_size), + true); } }