From patchwork Sat Jul 7 10:20:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 940783 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-481155-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cAHgtw+m"; 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 41N70J1KJdz9rxs for ; Sat, 7 Jul 2018 20:20:45 +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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=c32pDW0Nyu+2/UBf Hw0WUl1jMH7zgexKblGtM71Rsn0OsxrvF+Pe6jTDKudwe4XgMkdecsPvLyINt4ab 3YbPM046MmHz1WedPX61bfQ4yxjixgBjLRyA6sL1GZ+Wzh3IvS6y62Bv0GtjVCFb OH7VvEshUZ3eq/F4lRwdYyXapmg= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=WEaFFRD+9uIFUmDld9YX+Q 2/EKI=; b=cAHgtw+mEgm0MtnVSWragMtLcDNG9fKTJwSVUTnuVLIa2KpPF2ng77 NW20EqsZMXjd+ZGwy/+WN0k7C75dKU0IOW4iaOmpCjZtiWTomxWfFbjSG5oBx72G mKWZei2w8Du2HTBl4YSBOzLzU9Uv08sooFEPHeJ0qMdOfWM51oJmQ= Received: (qmail 52436 invoked by alias); 7 Jul 2018 10:20:37 -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 52421 invoked by uid 89); 7 Jul 2018 10:20:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=association, disturb, mere, Present X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 07 Jul 2018 10:20:35 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 3238282259 for ; Sat, 7 Jul 2018 12:20:33 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eVf-6O6XyDNS for ; Sat, 7 Jul 2018 12:20:33 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 024328223C for ; Sat, 7 Jul 2018 12:20:32 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Do not generate debug info for actual subtypes Date: Sat, 07 Jul 2018 12:20:30 +0200 Message-ID: <1574689.BLYs4ly5bf@polaris> MIME-Version: 1.0 These actual subtypes are artificial subtypes generated for parameters whose nominal subtype is an unconstrained array type in order to expose the bounds. There is no point in generating debug info for them so avoid doing it now. Tested on x86-64/Linux, applied on the mainline. 2018-07-07 Eric Botcazou * gcc-interface/gigi.h (add_decl_expr): Adjust prototype. * gcc-interface/decl.c (gnat_to_gnu_entity): Remove useless test. * gcc-interface/trans.c (add_stmt_with_node): Remove exceptions. (add_decl_expr): Change type of second parameter and rename it. (renaming_from_instantiation_p): New function moved from... (set_expr_location_from_node): Test for exceptions here and add one for actual subtypes built for unconstrained composite actuals. * gcc-interface/utils.c (renaming_from_instantiation_p): ...here. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 262495) +++ gcc-interface/decl.c (working copy) @@ -430,11 +430,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entit || Is_Public (gnat_entity)); /* Get the name of the entity and set up the line number and filename of - the original definition for use in any decl we make. Make sure we do not - inherit another source location. */ + the original definition for use in any decl we make. Make sure we do + not inherit another source location. */ gnu_entity_name = get_entity_name (gnat_entity); - if (Sloc (gnat_entity) != No_Location - && !renaming_from_instantiation_p (gnat_entity)) + if (!renaming_from_instantiation_p (gnat_entity)) Sloc_to_locus (Sloc (gnat_entity), &input_location); /* For cases when we are not defining (i.e., we are referencing from Index: gcc-interface/gigi.h =================================================================== --- gcc-interface/gigi.h (revision 262468) +++ gcc-interface/gigi.h (working copy) @@ -77,9 +77,9 @@ extern tree end_stmt_group (void); /* Set the BLOCK node corresponding to the current code group to GNU_BLOCK. */ extern void set_block_for_group (tree); -/* Add a declaration statement for GNU_DECL to the current BLOCK_STMT node. - Get SLOC from GNAT_ENTITY. */ -extern void add_decl_expr (tree gnu_decl, Entity_Id gnat_entity); +/* Add a declaration statement for GNU_DECL to the current statement group. + Get the SLOC to be put onto the statement from GNAT_NODE. */ +extern void add_decl_expr (tree gnu_decl, Node_Id gnat_node); /* Mark nodes rooted at T with TREE_VISITED and types as having their sized gimplified. We use this to indicate all variable sizes and Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 262496) +++ gcc-interface/trans.c (working copy) @@ -8119,9 +8119,7 @@ add_stmt_force (tree gnu_stmt) void add_stmt_with_node (tree gnu_stmt, Node_Id gnat_node) { - /* Do not emit a location for renamings that come from generic instantiation, - they are likely to disturb debugging. */ - if (Present (gnat_node) && !renaming_from_instantiation_p (gnat_node)) + if (Present (gnat_node)) set_expr_location_from_node (gnu_stmt, gnat_node); add_stmt (gnu_stmt); } @@ -8137,10 +8135,10 @@ add_stmt_with_node_force (tree gnu_stmt, } /* Add a declaration statement for GNU_DECL to the current statement group. - Get SLOC from Entity_Id. */ + Get the SLOC to be put onto the statement from GNAT_NODE. */ void -add_decl_expr (tree gnu_decl, Entity_Id gnat_entity) +add_decl_expr (tree gnu_decl, Node_Id gnat_node) { tree type = TREE_TYPE (gnu_decl); tree gnu_stmt, gnu_init; @@ -8179,7 +8177,7 @@ add_decl_expr (tree gnu_decl, Entity_Id MARK_VISITED (TYPE_ADA_SIZE (type)); } else - add_stmt_with_node (gnu_stmt, gnat_entity); + add_stmt_with_node (gnu_stmt, gnat_node); /* If this is a variable and an initializer is attached to it, it must be valid for the context. Similar to init_const in create_var_decl. */ @@ -8203,7 +8201,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnu_decl = convert (TREE_TYPE (TYPE_FIELDS (type)), gnu_decl); gnu_stmt = build_binary_op (INIT_EXPR, NULL_TREE, gnu_decl, gnu_init); - add_stmt_with_node (gnu_stmt, gnat_entity); + add_stmt_with_node (gnu_stmt, gnat_node); } } @@ -10005,6 +10003,32 @@ Sloc_to_locus (Source_Ptr Sloc, location return true; } +/* Return whether GNAT_NODE is a defining identifier for a renaming that comes + from the parameter association for the instantiation of a generic. We do + not want to emit source location for them: the code generated for their + initialization is likely to disturb debugging. */ + +bool +renaming_from_instantiation_p (Node_Id gnat_node) +{ + if (Nkind (gnat_node) != N_Defining_Identifier + || !Is_Object (gnat_node) + || Comes_From_Source (gnat_node) + || !Present (Renamed_Object (gnat_node))) + return false; + + /* Get the object declaration of the renamed object, if any and if the + renamed object is a mere identifier. */ + gnat_node = Renamed_Object (gnat_node); + if (Nkind (gnat_node) != N_Identifier) + return false; + + gnat_node = Parent (Entity (gnat_node)); + return (Present (gnat_node) + && Nkind (gnat_node) == N_Object_Declaration + && Present (Corresponding_Generic_Association (gnat_node))); +} + /* Similar to set_expr_location, but start with the Sloc of GNAT_NODE and don't do anything if it doesn't correspond to a source location. And, if CLEAR_COLUMN is true, set the column information to 0. */ @@ -10014,6 +10038,16 @@ set_expr_location_from_node (tree node, { location_t locus; + /* Do not set a location for constructs likely to disturb debugging. */ + if (Nkind (gnat_node) == N_Defining_Identifier) + { + if (Is_Type (gnat_node) && Is_Actual_Subtype (gnat_node)) + return; + + if (renaming_from_instantiation_p (gnat_node)) + return; + } + if (!Sloc_to_locus (Sloc (gnat_node), &locus, clear_column)) return; Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 262495) +++ gcc-interface/utils.c (working copy) @@ -2938,37 +2938,6 @@ value_factor_p (tree value, HOST_WIDE_IN return false; } -/* Return whether GNAT_NODE is a defining identifier for a renaming that comes - from the parameter association for the instantiation of a generic. We do - not want to emit source location for them: the code generated for their - initialization is likely to disturb debugging. */ - -bool -renaming_from_instantiation_p (Node_Id gnat_node) -{ - if (Nkind (gnat_node) != N_Defining_Identifier - || !Is_Object (gnat_node) - || Comes_From_Source (gnat_node) - || !Present (Renamed_Object (gnat_node))) - return false; - - /* Get the object declaration of the renamed object, if any and if the - renamed object is a mere identifier. */ - gnat_node = Renamed_Object (gnat_node); - if (Nkind (gnat_node) != N_Identifier) - return false; - - gnat_node = Entity (gnat_node); - if (!Present (Parent (gnat_node))) - return false; - - gnat_node = Parent (gnat_node); - return - (Present (gnat_node) - && Nkind (gnat_node) == N_Object_Declaration - && Present (Corresponding_Generic_Association (gnat_node))); -} - /* Defer the initialization of DECL's DECL_CONTEXT attribute, scheduling to feed it with the elaboration of GNAT_SCOPE. */