From patchwork Wed Nov 3 17:44:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 70042 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 6519AB6EEB for ; Thu, 4 Nov 2010 04:44:59 +1100 (EST) Received: (qmail 4806 invoked by alias); 3 Nov 2010 17:44:50 -0000 Received: (qmail 4711 invoked by uid 22791); 3 Nov 2010 17:44:48 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Wed, 03 Nov 2010 17:44:40 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA3HicKB016906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Nov 2010 13:44:39 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA3HibFB004550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 3 Nov 2010 13:44:38 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id oA3Hibc8026523; Wed, 3 Nov 2010 18:44:37 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oA3HibQH026521; Wed, 3 Nov 2010 18:44:37 +0100 Date: Wed, 3 Nov 2010 18:44:36 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Improve handling of is_const_type && is_volatile_type in modified_type_die (PR debug/45997) Message-ID: <20101103174436.GR29412@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! If both is_const_type and is_volatile_type are set, then we can either choose to start with DW_TAG_const_type, or DW_TAG_volatile_type. If we choose badly, we might end up with no qualified_type and an unnamed DW_TAG_base_type. The following patch fixes it by starting with DW_TAG_volatile_type if starting DW_TAG_const_type would lead to no qualified_type, while starting with DW_TAG_volatile_type works. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-11-03 Jakub Jelinek PR debug/45997 * dwarf2out.c (modified_type_die): If both is_const_type and is_volatile_type is set, start with DW_TAG_const_type or DW_TAG_volatile_type depending on where we get qualified type in the recursive call. * g++.dg/debug/dwarf2/pr45997-1.C: New test. * g++.dg/debug/dwarf2/pr45997-2.C: New test. Jakub --- gcc/dwarf2out.c.jj 2010-11-01 09:07:22.000000000 +0100 +++ gcc/dwarf2out.c 2010-11-03 14:43:37.000000000 +0100 @@ -12764,7 +12764,12 @@ modified_type_die (tree type, int is_con /* Else cv-qualified version of named type; fall through. */ } - if (is_const_type) + if (is_const_type + /* If both is_const_type and is_volatile_type, prefer the path + which leads to a qualified type. */ + && (!is_volatile_type + || get_qualified_type (type, TYPE_QUAL_CONST) == NULL_TREE + || get_qualified_type (type, TYPE_QUAL_VOLATILE) != NULL_TREE)) { mod_type_die = new_die (DW_TAG_const_type, comp_unit_die (), type); sub_die = modified_type_die (type, 0, is_volatile_type, context_die); @@ -12772,7 +12777,7 @@ modified_type_die (tree type, int is_con else if (is_volatile_type) { mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die (), type); - sub_die = modified_type_die (type, 0, 0, context_die); + sub_die = modified_type_die (type, is_const_type, 0, context_die); } else if (code == POINTER_TYPE) { --- gcc/testsuite/g++.dg/debug/dwarf2/pr45997-1.C.jj 2010-11-03 14:55:58.000000000 +0100 +++ gcc/testsuite/g++.dg/debug/dwarf2/pr45997-1.C 2010-11-03 14:57:08.000000000 +0100 @@ -0,0 +1,22 @@ +// PR debug/45997 +// { dg-do compile } +// { dg-options "-gdwarf-2 -dA" } + +typedef int my_int; +typedef const my_int const_my_int; +typedef volatile const_my_int volatile_const_my_int; + +my_int v_my_int = 0; +const_my_int v_const_my_int = 1; +volatile_const_my_int v_volatile_const_my_int = 4; + +int +main () +{ + asm volatile ("" : : "r" (&v_my_int)); + asm volatile ("" : : "r" (&v_const_my_int)); + asm volatile ("" : : "r" (&v_volatile_const_my_int)); + return 0; +} + +// { dg-final { scan-assembler-times "DIE\[^\n\r\]*DW_TAG_base_type" 1 } } --- gcc/testsuite/g++.dg/debug/dwarf2/pr45997-2.C.jj 2010-11-03 14:55:58.000000000 +0100 +++ gcc/testsuite/g++.dg/debug/dwarf2/pr45997-2.C 2010-11-03 14:57:33.000000000 +0100 @@ -0,0 +1,22 @@ +// PR debug/45997 +// { dg-do compile } +// { dg-options "-gdwarf-2 -dA" } + +typedef int my_int; +typedef volatile my_int volatile_my_int; +typedef const volatile_my_int const_volatile_my_int; + +my_int v_my_int = 0; +volatile_my_int v_volatile_my_int = 1; +const_volatile_my_int v_const_volatile_my_int = 4; + +int +main () +{ + asm volatile ("" : : "r" (&v_my_int)); + asm volatile ("" : : "r" (&v_volatile_my_int)); + asm volatile ("" : : "r" (&v_const_volatile_my_int)); + return 0; +} + +// { dg-final { scan-assembler-times "DIE\[^\n\r\]*DW_TAG_base_type" 1 } }