From patchwork Wed Feb 1 08:04:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 64067 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F3D6385B512 for ; Wed, 1 Feb 2023 08:05:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F3D6385B512 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675238728; bh=IqjC1LfLyeY1PtsEytgj+BDPkTYyTOY4vPR1PryxMmE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eSpLZCDSV/5clJtVTZjZQFLUihUdBvScMdyqNgbPgnmkTRpxbVxVJqFwQmp3ivg5k RrzlkbD8xxtPWgkoSt9+HqBSqBatw/Kdw3GYC/hm2EHd0GScl7sWhCE6TXKqUBQhHo 8Hh0t4+Dei901oJHKqEwUncHCdW2TUVpOlAoDRwk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 84A113858D38 for ; Wed, 1 Feb 2023 08:04:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84A113858D38 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3117fnuf040718 for ; Wed, 1 Feb 2023 08:04:50 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nfkb11cbf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 01 Feb 2023 08:04:49 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3117SbAa014730 for ; Wed, 1 Feb 2023 08:04:48 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3ncvttvgqp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 01 Feb 2023 08:04:48 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31184ju338797594 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 1 Feb 2023 08:04:45 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7EB62004B for ; Wed, 1 Feb 2023 08:04:45 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A883F20063 for ; Wed, 1 Feb 2023 08:04:45 +0000 (GMT) Received: from li-ecc9ffcc-3485-11b2-a85c-e633c5126265.ibm.com (unknown [9.152.224.239]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Wed, 1 Feb 2023 08:04:45 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/3] New reg note REG_CFA_NORESTORE Date: Wed, 1 Feb 2023 09:04:43 +0100 Message-Id: <20230201080445.10135-2-krebbel@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201080445.10135-1-krebbel@linux.ibm.com> References: <20230201080445.10135-1-krebbel@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: HLChizpakhhaUFVfw5MgqiQbeAIZCepd X-Proofpoint-GUID: HLChizpakhhaUFVfw5MgqiQbeAIZCepd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-01_03,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 malwarescore=0 phishscore=0 mlxscore=0 suspectscore=0 mlxlogscore=827 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302010070 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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: Andreas Krebbel via Gcc-patches From: Andreas Krebbel Reply-To: Andreas Krebbel Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch introduces a new reg note which can be used to tell the CFI verification in dwarf2cfi that a register is stored without intending to restore from it. This is useful when storing e.g. register contents to the stack and generate CFI for it although the register is not really supposed to be restored. gcc/ChangeLog: * dwarf2cfi.cc (dwarf2out_frame_debug_cfa_restore): Add EMIT_CFI parameter. (dwarf2out_frame_debug): Add case for REG_CFA_NORESTORE. * reg-notes.def (REG_CFA_NOTE): New reg note definition. --- gcc/dwarf2cfi.cc | 15 ++++++++++----- gcc/reg-notes.def | 5 +++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/gcc/dwarf2cfi.cc b/gcc/dwarf2cfi.cc index 1c70bd83f28..57283c10a29 100644 --- a/gcc/dwarf2cfi.cc +++ b/gcc/dwarf2cfi.cc @@ -1496,10 +1496,12 @@ dwarf2out_frame_debug_cfa_val_expression (rtx set) update_row_reg_save (cur_row, dwf_regno (dest), cfi); } -/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_RESTORE note. */ +/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_RESTORE + note. When called with EMIT_CFI set to false emitting a CFI + statement is suppressed. */ static void -dwarf2out_frame_debug_cfa_restore (rtx reg) +dwarf2out_frame_debug_cfa_restore (rtx reg, bool emit_cfi) { gcc_assert (REG_P (reg)); @@ -1507,7 +1509,8 @@ dwarf2out_frame_debug_cfa_restore (rtx reg) if (!span) { unsigned int regno = dwf_regno (reg); - add_cfi_restore (regno); + if (emit_cfi) + add_cfi_restore (regno); update_row_reg_save (cur_row, regno, NULL); } else @@ -1522,7 +1525,8 @@ dwarf2out_frame_debug_cfa_restore (rtx reg) reg = XVECEXP (span, 0, par_index); gcc_assert (REG_P (reg)); unsigned int regno = dwf_regno (reg); - add_cfi_restore (regno); + if (emit_cfi) + add_cfi_restore (regno); update_row_reg_save (cur_row, regno, NULL); } } @@ -2309,6 +2313,7 @@ dwarf2out_frame_debug (rtx_insn *insn) break; case REG_CFA_RESTORE: + case REG_CFA_NO_RESTORE: n = XEXP (note, 0); if (n == NULL) { @@ -2317,7 +2322,7 @@ dwarf2out_frame_debug (rtx_insn *insn) n = XVECEXP (n, 0, 0); n = XEXP (n, 0); } - dwarf2out_frame_debug_cfa_restore (n); + dwarf2out_frame_debug_cfa_restore (n, REG_NOTE_KIND (note) == REG_CFA_RESTORE); handled_one = true; break; diff --git a/gcc/reg-notes.def b/gcc/reg-notes.def index 23de1f13ee9..1f74a605b3e 100644 --- a/gcc/reg-notes.def +++ b/gcc/reg-notes.def @@ -157,6 +157,11 @@ REG_CFA_NOTE (CFA_VAL_EXPRESSION) first pattern is the register to be restored. */ REG_CFA_NOTE (CFA_RESTORE) +/* Like CFA_RESTORE but without actually emitting CFI. This can be + used to tell the verification infrastructure that a register is + saved without intending to restore it. */ +REG_CFA_NOTE (CFA_NO_RESTORE) + /* Attached to insns that are RTX_FRAME_RELATED_P, marks insn that sets vDRAP from DRAP. If vDRAP is a register, vdrap_reg is initalized to the argument, if it is a MEM, it is ignored. */