From patchwork Fri Nov 19 09:40:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 47924 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 0A57A3858C39 for ; Fri, 19 Nov 2021 09:41:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A57A3858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637314882; bh=br/qf6/Belip954rLAm0l1h5wzjadu2ErPLftU4/3Ug=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=eoMGcrC64fu352bFjn/YWa2KKODx9AHdusJkKZnHa1LsQlMdbmcBDuyHFnBluS3lE EZktaWFaFx2/AbQop2pfirynJg19GOO+ncTGgtP5iXGwQoEH86fzobUVi2ZdD8E0OG 22eSQqDGkqaiFsVtfhfqVgEdwn66qMhCZZMOuxZM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E73BC3858D3C for ; Fri, 19 Nov 2021 09:40:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E73BC3858D3C Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-148-_t7Izpt0MqKLUaSQThHAyg-1; Fri, 19 Nov 2021 04:40:35 -0500 X-MC-Unique: _t7Izpt0MqKLUaSQThHAyg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 61958802C98; Fri, 19 Nov 2021 09:40:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0AC215F4ED; Fri, 19 Nov 2021 09:40:33 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1AJ9eQSm4025605 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 19 Nov 2021 10:40:26 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1AJ9ePWu4025604; Fri, 19 Nov 2021 10:40:25 +0100 Date: Fri, 19 Nov 2021 10:40:25 +0100 To: fortran@gcc.gnu.org Subject: [PATCH] fortran, debug: Fix up DW_AT_rank [PR103315] Message-ID: <20211119094025.GL2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! For DW_AT_rank we were emitting .uleb128 0x4 # DW_AT_rank .byte 0x97 # DW_OP_push_object_address .byte 0x23 # DW_OP_plus_uconst .uleb128 0x1c .byte 0x6 # DW_OP_deref on 64-bit and .uleb128 0x4 # DW_AT_rank .byte 0x97 # DW_OP_push_object_address .byte 0x23 # DW_OP_plus_uconst .uleb128 0x10 .byte 0x6 # DW_OP_deref on 32-bit. I think this is wrong, as dtype.rank field in the descriptor has unsigned char type, not pointer type nor pointer sized integral. E.g. if we have a REAL :: a(..) dummy argument, which is passed as a reference to the function descriptor, we want to evaluate a->dtype.rank. The above DWARF expressions perform *(uintptr_t *)(a + 0x1c) and *(uintptr_t *)(a + 0x10) respectively. The following patch changes those to: .uleb128 0x5 # DW_AT_rank .byte 0x97 # DW_OP_push_object_address .byte 0x23 # DW_OP_plus_uconst .uleb128 0x1c .byte 0x94 # DW_OP_deref_size .byte 0x1 and .uleb128 0x5 # DW_AT_rank .byte 0x97 # DW_OP_push_object_address .byte 0x23 # DW_OP_plus_uconst .uleb128 0x10 .byte 0x94 # DW_OP_deref_size .byte 0x1 which perform *(unsigned char *)(a + 0x1c) and *(unsigned char *)(a + 0x10) respectively. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2021-11-19 Jakub Jelinek PR debug/103315 * trans-types.c (gfc_get_array_descr_info): Use DW_OP_deref_size 1 instead of DW_OP_deref for DW_AT_rank. Jakub --- gcc/fortran/trans-types.c.jj 2021-11-12 15:54:21.000000000 +0100 +++ gcc/fortran/trans-types.c 2021-11-18 15:13:45.131281198 +0100 @@ -3459,8 +3459,8 @@ gfc_get_array_descr_info (const_tree typ if (!integer_zerop (dtype_off)) t = fold_build_pointer_plus (t, rank_off); - t = build1 (NOP_EXPR, build_pointer_type (gfc_array_index_type), t); - t = build1 (INDIRECT_REF, gfc_array_index_type, t); + t = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (field)), t); + t = build1 (INDIRECT_REF, TREE_TYPE (field), t); info->rank = t; t = build0 (PLACEHOLDER_EXPR, TREE_TYPE (dim_off)); t = size_binop (MULT_EXPR, t, dim_size);