From patchwork Tue Nov 30 23:07:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 73678 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]) by ozlabs.org (Postfix) with SMTP id 19B07B70DA for ; Wed, 1 Dec 2010 10:07:23 +1100 (EST) Received: (qmail 20459 invoked by alias); 30 Nov 2010 23:07:21 -0000 Received: (qmail 20448 invoked by uid 22791); 30 Nov 2010 23:07:19 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_GD, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Nov 2010 23:07:14 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAUN7ChP005012 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 30 Nov 2010 18:07:13 -0500 Received: from [127.0.0.1] (ovpn-113-75.phx2.redhat.com [10.3.113.75]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAUN7BKl010955; Tue, 30 Nov 2010 18:07:12 -0500 Message-ID: <4CF5839F.1080608@redhat.com> Date: Tue, 30 Nov 2010 18:07:11 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101116 Lightning/1.0b1 Shredder/3.0.11pre MIME-Version: 1.0 To: Jakub Jelinek CC: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix ICE with -feliminate-dwarf2-dups or -gdwarf-4 (PR debug/46123) References: <20101118204216.GB29412@tyan-ft48-01.lab.bos.redhat.com> <4CED968D.80208@redhat.com> <4CEF26F4.6030303@redhat.com> <20101126112622.GL29412@tyan-ft48-01.lab.bos.redhat.com> <20101126134116.GM29412@tyan-ft48-01.lab.bos.redhat.com> <4CEFCA91.3010906@redhat.com> <20101126163706.GP29412@tyan-ft48-01.lab.bos.redhat.com> <4CF09C4B.7060009@redhat.com> In-Reply-To: <4CF09C4B.7060009@redhat.com> 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 On 11/27/2010 12:51 AM, Jason Merrill wrote: > Right, so the concrete instance needs to move to be under comp_unit_die. The problem with this is that separating the abstract and concrete instances between CUs means we need more symbolic refs, since not only the function itself has AT_abstract_origin. So that's not the right fix. I poked around at this for a while myself; I was puzzled as to why we were trying to put the local type in a comdat unit in the first place, since it's internal to a function. It turned out that we were wrongly attaching the local type to the declaration die for the containing function; fixing that makes your testcases pass. Does this patch make sense to you? commit 61e1c85d04c7f2e57b5e4da45c904479f82c240e Author: Jason Merrill Date: Mon Nov 29 20:30:04 2010 -0500 PR debug/46123 * dwarf2out.c (gen_tagged_type_die): Don't put local types in a declaration DIE. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index e230861..b6a26c8 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -20186,6 +20186,10 @@ gen_tagged_type_die (tree type, out yet, use a NULL context for now; it will be fixed up in decls_for_scope. */ context_die = lookup_decl_die (TYPE_CONTEXT (type)); + /* A declaration DIE doesn't count; nested types need to go in the + specification. */ + if (is_declaration_die (context_die)) + context_die = NULL; need_pop = 0; } else diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr46123.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr46123.C new file mode 100644 index 0000000..eee192c --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr46123.C @@ -0,0 +1,47 @@ +// PR debug/46123 +// { dg-do compile } +// { dg-options "-gdwarf-4" } + +struct foo +{ + static int bar () + { + int i; + static int baz = 1; + { + static int baz = 2; + i = baz++; + } + { + struct baz + { + static int m () + { + static int n; + return n += 10; + } + }; + baz a; + i += a.m (); + } + { + static int baz = 3; + i += baz; + baz += 30; + } + i += baz; + baz += 60; + return i; + } +}; + +int main () +{ + foo x; + + if (x.bar () != 16) + return 1; + if (x.bar() != 117) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.dg/debug/pr46123.C b/gcc/testsuite/g++.dg/debug/pr46123.C new file mode 100644 index 0000000..9e115cd --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr46123.C @@ -0,0 +1,47 @@ +// PR debug/46123 +// { dg-do compile } +// { dg-options "-g -feliminate-dwarf2-dups" } + +struct foo +{ + static int bar () + { + int i; + static int baz = 1; + { + static int baz = 2; + i = baz++; + } + { + struct baz + { + static int m () + { + static int n; + return n += 10; + } + }; + baz a; + i += a.m (); + } + { + static int baz = 3; + i += baz; + baz += 30; + } + i += baz; + baz += 60; + return i; + } +}; + +int main () +{ + foo x; + + if (x.bar () != 16) + return 1; + if (x.bar() != 117) + return 1; + return 0; +}