From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2063) id 6E98B3858D3C; Wed, 19 Oct 2022 11:23:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E98B3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666178639; bh=/G0ZJD8lIi6UvC4tiREI0ZG1Y6WSMzIgHZFGXa581eg=; h=From:To:Subject:Date:From; b=D3vMpBBk2SBdeDJJPp8KPdNJVLnfOtIPLKMfXsIOa3FFapAgQAoe+jvJnlipoYREo ecsmDFp9w70DfI2KrWXhJBTD/c1cGpYPO0syhCQkS9PoeSlo9ECkd9pd2DQdMwVPSI sQkGfzrFkt32K7riHOttGILhzeElYT2Z4+gD+yMY= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kewen Lin To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10322] rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072] X-Act-Checkin: gcc X-Git-Author: Kewen Lin X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 6445c753c933f4ef6cca219224400a0bd2b0c4f5 X-Git-Newrev: 25b6cbe8a9abd5ad9b05f23f00f9ae68aa105c99 Message-Id: <20221019112359.6E98B3858D3C@sourceware.org> Date: Wed, 19 Oct 2022 11:23:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:25b6cbe8a9abd5ad9b05f23f00f9ae68aa105c99 commit r11-10322-g25b6cbe8a9abd5ad9b05f23f00f9ae68aa105c99 Author: Kewen Lin Date: Mon Sep 26 00:33:18 2022 -0500 rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072] As PR96072 shows, the code adding REG_CFA_DEF_CFA reg note makes one assumption that we have emitted one insn which restores the frame pointer previously. That part of code was guarded with flag frame_pointer_needed before, it was consistent, but it was replaced with flag frame_pointer_needed_indeed since commit r10-7981. It caused ICE due to unexpected NULL insn. PR target/96072 gcc/ChangeLog: * config/rs6000/rs6000-logue.c (rs6000_emit_epilogue): Update the condition for adding REG_CFA_DEF_CFA reg note with frame_pointer_needed_indeed. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr96072.c: New test. (cherry picked from commit 5be0950d22209f5ba69d244387228e12389a8470) Diff: --- gcc/config/rs6000/rs6000-logue.c | 2 +- gcc/testsuite/gcc.target/powerpc/pr96072.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c index 9965a8aa691..bdcb37c72f5 100644 --- a/gcc/config/rs6000/rs6000-logue.c +++ b/gcc/config/rs6000/rs6000-logue.c @@ -4924,7 +4924,7 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type) a REG_CFA_DEF_CFA note, but that's OK; A duplicate is discarded by dwarf2cfi.c/dwarf2out.c, and in any case would be harmless if emitted. */ - if (frame_pointer_needed) + if (frame_pointer_needed_indeed) { insn = get_last_insn (); add_reg_note (insn, REG_CFA_DEF_CFA, diff --git a/gcc/testsuite/gcc.target/powerpc/pr96072.c b/gcc/testsuite/gcc.target/powerpc/pr96072.c new file mode 100644 index 00000000000..10341c91d2f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr96072.c @@ -0,0 +1,14 @@ +/* { dg-options "-O2" } */ + +/* This used to ICE with the SYSV ABI (PR96072). */ + +void +he (int jn) +{ + { + int bh[jn]; + if (jn != 0) + goto wa; + } +wa:; +}