From patchwork Thu May 2 18:24:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 1094491 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-500017-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="KGZNPbaA"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44w3Zv6xQHz9sBV for ; Fri, 3 May 2019 04:24:50 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=K/VmHfAp4rpO HadpK0/a9qObnl9lBwWTIJZKeYn93P7iiQ8JR51EOHNpQjW7bs/g2Wt8I8zqKWpg efKWoTrGUL3nJozSVFlciFrtv4vJHuwqiuGf+36L0Jj/RlcfShgKETK9iBH4YPhk 5Hw8jQ0JHf66afHhLdpUjeIqH3Rk6h8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=vKoVSfSwAEhrW/XjwW wn8SdJWjo=; b=KGZNPbaAUuiww9PgafwiyDa1Qwkc9rIFxX7yl5jXWxbcqdUTDB ox9/SM2VGhSFSrSVz8nP8FcBdrvuYGVf81iiKtiEodCuFlfm4+xEDPbfu+kjMz3/ Dpmf/D+q02Ei8/yVVa5UTfw0JdMWsS/dzrQeUukVIhleVShx7j5kCRz6k= Received: (qmail 1304 invoked by alias); 2 May 2019 18:24:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1164 invoked by uid 89); 2 May 2019 18:24:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=rs6000c, rs6000.c, sk:rs6000_, UD:rs6000.c X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 May 2019 18:24:22 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 1B6001240940; Thu, 2 May 2019 18:24:12 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, Segher Boessenkool Subject: [PATCH 1/2] rs6000: Debug regnums for TM registers Date: Thu, 2 May 2019 18:24:10 +0000 Message-Id: X-IsSubscribed: yes Since GCC 8, we have output incorrect numbers for the transactional memory registers. Also, we didn't output the correct DWARF register numbers for those. The number for sprN is 100+N. This fixes both these issues. Tested on powerpc64-linux (-m32,-m64} and on powerpc64le-linux. Committing. I hope this (and the next patch) doesn't break targets using the old DWARF register numbers, I cannot easily test that; but it's stage 1. This should be backported to GCC 8 and GCC 9 (9.2). Segher 2019-05-02 Segher Boessenkool * config/rs6000/rs6000.c (rs6000_dbx_register_number): Return the correct numbers for TFHAR, TFIAR, TEXASR. --- gcc/config/rs6000/rs6000.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index f0de18d..f8e9fd2 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -36269,10 +36269,20 @@ rs6000_init_dwarf_reg_sizes_extra (tree address) unsigned int rs6000_dbx_register_number (unsigned int regno, unsigned int format) { - /* Except for the above, we use the internal number for non-DWARF - debug information, and also for .eh_frame. */ + /* We use the GCC 7 (and before) internal number for non-DWARF debug + information, and also for .eh_frame. */ if ((format == 0 && write_symbols != DWARF2_DEBUG) || format == 2) - return regno; + { + /* Translate the regnos to their numbers in GCC 7 (and before). */ + if (regno == TFHAR_REGNO) + regno = 114; + else if (regno == TFIAR_REGNO) + regno = 115; + else if (regno == TEXASR_REGNO) + regno = 116; + + return regno; + } /* On some platforms, we use the standard DWARF register numbering for .debug_info and .debug_frame. */ @@ -36299,6 +36309,12 @@ rs6000_dbx_register_number (unsigned int regno, unsigned int format) return 356; if (regno == VSCR_REGNO) return 67; + if (regno == TFHAR_REGNO) + return 228; + if (regno == TFIAR_REGNO) + return 229; + if (regno == TEXASR_REGNO) + return 230; #endif return regno; } From patchwork Thu May 2 18:24:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 1094492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-500018-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="agjCjyzM"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44w3b03MLTz9sBr for ; Fri, 3 May 2019 04:25:00 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=KFIElDubcV+8C1t5NwG aLDMCw/MqKVqsLvT1K5PEMzltM6Gk9Pw9wCUrMeAs1EDNlyh3kewCF0sCjKzZ4Wh 6FFCj4alB6J71UO8GBHOMVX7aVbMNgv8W420USnsb4ODZ3rQDRW6zuIOLQJtkVY4 BvkTnSnr8Z10h2pT2WMDCAqw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=OOzvakYx208WNlhhuL67M59rt s0=; b=agjCjyzMu7BGh9qIkK8HszOuLygsu5YdKzHEg90pYAWZLidoRy8GYfOzL Uwd606SdSZkYjlAQ3NAE98aafaKyUQVFfQigM0vdJq9PjsFtyqgEFtwAzD23DGZF b+2Udz7Hwy+2r1iGqw7IwPzz3FWGmmFp9xHTUxuM7APLYwUAMk= Received: (qmail 1361 invoked by alias); 2 May 2019 18:24:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1258 invoked by uid 89); 2 May 2019 18:24:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=rs6000c, rs6000.c, sk:rs6000_, UD:rs6000.c X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 May 2019 18:24:22 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id C1BB11240942; Thu, 2 May 2019 18:24:17 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, Segher Boessenkool Subject: [PATCH 2/2] rs6000: Make debug regnums independent of internal ones Date: Thu, 2 May 2019 18:24:11 +0000 Message-Id: <41bc1f64ea282719313370cb9106bf288dcba055.1556818314.git.segher@kernel.crashing.org> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Where we use "internal GCC register numbers" in debug info, that defines an ABI, so we cannot change those numbers. But we want to change the internal numbers, and sometimes we do that without remembering this gotcha anyway; so let's make everything independent of the internal numbers. For those registers that are not recognised here (we still have MQ for example, but also the GCC-internal frame pointer and arg pointer registers), this just returns the internal register number. This is a bit worrying: that number could be the same as that for a register we validly want to have in debug info. I first had a gcc_unreachable () for that, but this does now work because dwarf2cfi calls rs6000_dbx_register_number for every internal register. Then I just returned 0 for the internal regs, but that causes various regression tests to fail. So now I return the internal register number again, as it was before; but this needs to be fixed. Tested on Linux, as the previous patch. Committing to trunk. Segher 2019-05-02 Segher Boessenkool * config/rs6000/rs6000.c (rs6000_dbx_register_number): Do not use the internal register number, for any "real" register. --- gcc/config/rs6000/rs6000.c | 107 +++++++++++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index f8e9fd2..c75fd86 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -36269,53 +36269,74 @@ rs6000_init_dwarf_reg_sizes_extra (tree address) unsigned int rs6000_dbx_register_number (unsigned int regno, unsigned int format) { - /* We use the GCC 7 (and before) internal number for non-DWARF debug - information, and also for .eh_frame. */ - if ((format == 0 && write_symbols != DWARF2_DEBUG) || format == 2) - { - /* Translate the regnos to their numbers in GCC 7 (and before). */ - if (regno == TFHAR_REGNO) - regno = 114; - else if (regno == TFIAR_REGNO) - regno = 115; - else if (regno == TEXASR_REGNO) - regno = 116; - - return regno; - } - /* On some platforms, we use the standard DWARF register numbering for .debug_info and .debug_frame. */ + if ((format == 0 && write_symbols == DWARF2_DEBUG) || format == 1) + { #ifdef RS6000_USE_DWARF_NUMBERING - if (regno <= 63) - return regno; - if (regno == LR_REGNO) - return 108; - if (regno == CTR_REGNO) - return 109; - /* Special handling for CR for .debug_frame: rs6000_emit_prologue has - translated any combination of CR2, CR3, CR4 saves to a save of CR2. - The actual code emitted saves the whole of CR, so we map CR2_REGNO - to the DWARF reg for CR. */ - if (format == 1 && regno == CR2_REGNO) - return 64; - if (CR_REGNO_P (regno)) - return regno - CR0_REGNO + 86; - if (regno == CA_REGNO) - return 101; /* XER */ - if (ALTIVEC_REGNO_P (regno)) - return regno - FIRST_ALTIVEC_REGNO + 1124; - if (regno == VRSAVE_REGNO) - return 356; - if (regno == VSCR_REGNO) - return 67; - if (regno == TFHAR_REGNO) - return 228; - if (regno == TFIAR_REGNO) - return 229; - if (regno == TEXASR_REGNO) - return 230; + if (regno <= 31) + return regno; + if (FP_REGNO_P (regno)) + return regno - FIRST_FPR_REGNO + 32; + if (ALTIVEC_REGNO_P (regno)) + return regno - FIRST_ALTIVEC_REGNO + 1124; + if (regno == LR_REGNO) + return 108; + if (regno == CTR_REGNO) + return 109; + if (regno == CA_REGNO) + return 101; /* XER */ + /* Special handling for CR for .debug_frame: rs6000_emit_prologue has + translated any combination of CR2, CR3, CR4 saves to a save of CR2. + The actual code emitted saves the whole of CR, so we map CR2_REGNO + to the DWARF reg for CR. */ + if (format == 1 && regno == CR2_REGNO) + return 64; + if (CR_REGNO_P (regno)) + return regno - CR0_REGNO + 86; + if (regno == VRSAVE_REGNO) + return 356; + if (regno == VSCR_REGNO) + return 67; + if (regno == TFHAR_REGNO) + return 228; + if (regno == TFIAR_REGNO) + return 229; + if (regno == TEXASR_REGNO) + return 230; + + return regno; #endif + } + + /* We use the GCC 7 (and before) internal number for non-DWARF debug + information, and also for .eh_frame. */ + /* Translate the regnos to their numbers in GCC 7 (and before). */ + if (regno <= 31) + return regno; + if (FP_REGNO_P (regno)) + return regno - FIRST_FPR_REGNO + 32; + if (ALTIVEC_REGNO_P (regno)) + return regno - FIRST_ALTIVEC_REGNO + 77; + if (regno == LR_REGNO) + return 65; + if (regno == CTR_REGNO) + return 66; + if (regno == CA_REGNO) + return 76; /* XER */ + if (CR_REGNO_P (regno)) + return regno - CR0_REGNO + 68; + if (regno == VRSAVE_REGNO) + return 109; + if (regno == VSCR_REGNO) + return 110; + if (regno == TFHAR_REGNO) + return 114; + if (regno == TFIAR_REGNO) + return 115; + if (regno == TEXASR_REGNO) + return 116; + return regno; }