From patchwork Mon Jun 15 16:34:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 484422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 1C005140216 for ; Tue, 16 Jun 2015 02:35:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=v4I5SxY/; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=xM+kiWJ59cbAlyYRRJa5VLiIi6c/AgYKLfmqqofUUc3Iga xVz6dOAlRnMSUxTpK4tUyySAoR2zR79qwVziDG7qAdJ9ABGeHT+G68cgP7JWSiyY cOfWJKffWXUneYSZX3dR1ZAUg/KtcZtvD63w022DtweDtNqOPDB6+Ddqzt1CA= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=Y6If0m9PuqfhoLMSmmgQSBWWrOw=; b=v4I5SxY/RXF4aH5JAGvu 9kzo7Pf8GSict9U4MtAYVWn+5hQv9est3tb3BPcdEW89xnsspvpN8Lj4d1uOcySV xaaMVMuWp1+nTgdFWG+fn1owNP8BhgJPsKB5uSnIbkWPCdsMNpcdjylnJhTkqciP mzhoRg0vrtrnF9zvliBcFww= Received: (qmail 44213 invoked by alias); 15 Jun 2015 16:34:39 -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 44137 invoked by uid 89); 15 Jun 2015 16:34:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 15 Jun 2015 16:34:34 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D4817C9B3D for ; Mon, 15 Jun 2015 16:34:32 +0000 (UTC) Received: from reynosa.quesejoda.com (unused [10.10.51.152] (may be forged)) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5FGYVYo017468 for ; Mon, 15 Jun 2015 12:34:31 -0400 Message-ID: <557EFE96.3010309@redhat.com> Date: Mon, 15 Jun 2015 09:34:30 -0700 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches Subject: [committed] PR debug/66535: guard check into parent's DIE The problem here is that the cached DIE does not have a parent because we purposely removed it, hoping that decls_for_scope will fill it in: /* If we're a nested function, initially use a parent of NULL; if we're a plain function, this will be fixed up in decls_for_scope. If we're a method, it will be ignored, since we already have a DIE. */ However, for the failing Ada testcase it _is_ decls_for_scope that we're being called from while we're doing the abstract instance dance while generating the containing type: gen_typedef_die(): ... origin = decl_ultimate_origin (decl); if (origin != NULL) add_abstract_origin_attribute (type_die, origin); So...we haven't yet filled in the parent. It doesn't really matter. We'll get it right, and besides, we shouldn't be dereferencing a parent's die field without checking the existence of said parent. Long story short... committing as obvious. Aldy commit ee39c82907a029fe1403cf1d3a364b89e9dee998 Author: Aldy Hernandez Date: Mon Jun 15 09:19:45 2015 -0700 PR debug/66535 * dwarf2out.c (gen_subprogram_die): Do not check a parent's tag if there is no parent. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index d2c516a..4fe33f8 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -18790,7 +18790,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) end function end module */ - || old_die->die_parent->die_tag == DW_TAG_module + || (old_die->die_parent + && old_die->die_parent->die_tag == DW_TAG_module) || context_die == NULL) && (DECL_ARTIFICIAL (decl) || (get_AT_file (old_die, DW_AT_decl_file) == file_index diff --git a/gcc/testsuite/gnat.dg/debug4.adb b/gcc/testsuite/gnat.dg/debug4.adb new file mode 100644 index 0000000..1ec37c2 --- /dev/null +++ b/gcc/testsuite/gnat.dg/debug4.adb @@ -0,0 +1,10 @@ +-- { dg-compile } +-- { dg-options "-g" } + +with Debug4_Pkg; + +procedure Debug4 is + package P is new Debug4_Pkg (Natural); +begin + null; +end; diff --git a/gcc/testsuite/gnat.dg/debug4_pkg.adb b/gcc/testsuite/gnat.dg/debug4_pkg.adb new file mode 100644 index 0000000..18ba0c0 --- /dev/null +++ b/gcc/testsuite/gnat.dg/debug4_pkg.adb @@ -0,0 +1,23 @@ +package body Debug4_Pkg is + + type Vertex_To_Vertex_T is array (Vertex_Id range <>) of Vertex_Id; + + function Dominator_Tree_Internal (G : T'Class) return Vertex_To_Vertex_T is + subtype V_To_V is Vertex_To_Vertex_T (0 .. G.Vertices.Last_Index); + type V_To_VIL is array + (Valid_Vertex_Id range 1 .. G.Vertices.Last_Index) + of Vertex_Index_List; + Bucket : V_To_VIL := (others => VIL.Empty_Vector); + Dom : V_To_V := (others => 0); + begin + return Dom; + end; + + function Dominator_Tree (G : T'Class) return T is + Dom : constant Vertex_To_Vertex_T := Dominator_Tree_Internal (G); + DT : T := (Vertices => VL.Empty_Vector); + begin + return DT; + end; + +end Debug4_Pkg; diff --git a/gcc/testsuite/gnat.dg/debug4_pkg.ads b/gcc/testsuite/gnat.dg/debug4_pkg.ads new file mode 100644 index 0000000..bac4953 --- /dev/null +++ b/gcc/testsuite/gnat.dg/debug4_pkg.ads @@ -0,0 +1,28 @@ +with Ada.Containers.Vectors; + +generic + type Vertex_Key is private; +package Debug4_Pkg is + + type Vertex_Id is new Natural; + subtype Valid_Vertex_Id is Vertex_Id range 1 .. Vertex_Id'Last; + + package VIL is new Ada.Containers.Vectors + (Index_Type => Positive, + Element_Type => Valid_Vertex_Id); + use VIL; + subtype Vertex_Index_List is VIL.Vector; + + package VL is new Ada.Containers.Vectors + (Index_Type => Valid_Vertex_Id, + Element_Type => Vertex_Key); + use VL; + subtype Vertex_List is VL.Vector; + + type T is tagged record + Vertices : Vertex_List; + end record; + + function Dominator_Tree (G : T'Class) return T; + +end Debug4_Pkg;