From patchwork Tue Jun 23 15:39:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1315373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=adacore-com.20150623.gappssmtp.com header.i=@adacore-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=PtQEF4Su; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49rsPM3Zhcz9sRR for ; Wed, 24 Jun 2020 02:36:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1979396EC8C; Tue, 23 Jun 2020 16:36:43 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 756BF396EC7F for ; Tue, 23 Jun 2020 16:36:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 756BF396EC7F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=botcazou@adacore.com Received: by mail-wr1-x434.google.com with SMTP id s10so1282990wrw.12 for ; Tue, 23 Jun 2020 09:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=yZdGlPqpzsSoJwUJUt9Kr43unQogdOLaUjtg60Et6bU=; b=PtQEF4SuBdsQ/7Kyt67jtDoR50xfYeoV//+uda1Ohbu0q2N57vNXjmhP/2CiUrIzTj l/dNmxPamaZai7lh9DnCkff/qKNtwQG2R7EcnK+3y3A+swW6js8nhA6meeAA7HkEJPmd 3b/OYy0YLNJ1Rtk8waAyYW/3tMKui0eX1Ds9DyVBIm7L8yXeTXZtDdd/u19noXUYwveh 1r7AKy0/2le/pLcw4VI/cgce6oMhQpE7rZAEHlNQJMLnOJtCd8/txeGQAMh9YkrLyIKu tMR+3vc3SFfBVtG48jrvruq6Rbab75PIL1rlwqO6OMMi4TTAUlx/OA0tx9OD5oyRmDnn ZM6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=yZdGlPqpzsSoJwUJUt9Kr43unQogdOLaUjtg60Et6bU=; b=fGOeRXXH4STwaD4Q4vYMUHFAIJ5ZGuCiHaK8tg0bW7bn/yehauWQ6ct0gSwqkTrp98 zWbNldk0YcwOTuSEJTarcN7XHpvS1YMOtjq+GmsE1/6GOiouP6dJomQwRtVLq081zmQQ mGMAPnvF6aSMTfoA5ap7769hhyeUHpb+R3ou+J51dxNc130UEqeuZ3nGJsuTwxJSylO4 HT7fTFRwkSk3zQeK329MKSPtAK7V3tAYwVnQk5F/eIIhYHtSiSIjHUDPk/+fiqAY/h1s fIUErUYE1NuUX6wtIrye1JQWZhX3iJDp/tliSNtJ7MDDaaNLc3j933PGz6bmErQJPt57 nAXA== X-Gm-Message-State: AOAM530oXIecPcPEINOG5DzIQCn9UVJxtnr3NkDqO3gMybGr7bE+4N2J EFDzqYZ81ifu6tXfGN09B0gGNM/oTrX7+Q== X-Google-Smtp-Source: ABdhPJxQWD4N3xQsSbVNxgQgRrWPYy7IyxFGdtyfYJWbby7BQJcBWstjNqQP3QvQblobJCtqmJ7SVA== X-Received: by 2002:adf:ce8d:: with SMTP id r13mr24338193wrn.392.1592930200349; Tue, 23 Jun 2020 09:36:40 -0700 (PDT) Received: from polaris.localnet ([2a01:e0a:41b:9230:1a03:73ff:fe45:373a]) by smtp.gmail.com with ESMTPSA id v24sm27023789wrd.92.2020.06.23.09.36.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jun 2020 09:36:39 -0700 (PDT) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Emit user subtypes with -fgnat-encodings=minimal Date: Tue, 23 Jun 2020 17:39:21 +0200 Message-ID: <3378180.knUNNaJMl6@polaris> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@gcc.gnu.org Sender: "Gcc-patches" This changes the compiler to emit debug info for user-defined subtypes even with -fgnat-encodings=minimal, as they might be needed by the debugger. Tested on x86-64/Linux, applied on the mainline. 2020-06-23 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Set the debug type to the base type and only if the subtype is artificial. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 33d59d556a2..589154ba392 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -3507,18 +3507,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) gnu_type = make_node (RECORD_TYPE); TYPE_NAME (gnu_type) = gnu_entity_name; - if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL) - { - /* Use the ultimate base record type as the debug type. - Subtypes and derived types bring no useful - information. */ - Entity_Id gnat_debug_type = gnat_entity; - while (Etype (gnat_debug_type) != gnat_debug_type) - gnat_debug_type = Etype (gnat_debug_type); - tree gnu_debug_type - = TYPE_MAIN_VARIANT (gnat_to_gnu_type (gnat_debug_type)); - SET_TYPE_DEBUG_TYPE (gnu_type, gnu_debug_type); - } TYPE_PACKED (gnu_type) = TYPE_PACKED (gnu_base_type); TYPE_REVERSE_STORAGE_ORDER (gnu_type) = Reverse_Storage_Order (gnat_entity); @@ -3580,6 +3568,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) true, debug_info_p, NULL, gnat_entity); } + + /* Or else, if the subtype is artificial and encodings are not + used, use the base record type as the debug type. */ + else if (debug_info_p + && artificial_p + && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL) + SET_TYPE_DEBUG_TYPE (gnu_type, gnu_unpad_base_type); } /* Otherwise, go down all the components in the new type and make