From patchwork Tue Jul 8 18:12:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 367987 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 3EEA414009E for ; Wed, 9 Jul 2014 04:12:31 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:content-transfer-encoding; q=dns; s= default; b=Ugj1fMGV5NvWjZt6N/SMlCkqDUuu6tkKOFoqZ7cIjDp1ibhL2rfgu dloVPfFcL80+qlM5xYUeoV+wgSs39YwiSa9gY6UOAJDSF7jkas2ZRhXgKJiY54Bp eEYPEnxvOq686gW9JY8SYFmZN7cGJs97YdCym9Wbc2NJ/Nn2H04n3w= 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 :subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:content-transfer-encoding; s=default; bh=Iy1VO3Xi8FUDVZRvLDhPQrXKtuQ=; b=miN/16HUBkzKGD4bKGc2yqA3vKnN NRCG0AiTqW2UMehmMiJgrZDqulAIdsvETWgKAIplvle6Ud6t2PaLyPK4Kqwbf4fe xt2YCWKH3zE2wHvJH1PMRft//5mVc/4TqvSZlHs9TUbEVsfgxvoXVxTMewfakFmx 9SRqGrgIcNVq+Oc= Received: (qmail 3874 invoked by alias); 8 Jul 2014 18:12:24 -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 3856 invoked by uid 89); 8 Jul 2014 18:12:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham 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; Tue, 08 Jul 2014 18:12:21 +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.14.4/8.14.4) with ESMTP id s68ICGEd016636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Jul 2014 14:12:17 -0400 Received: from [10.36.116.100] (ovpn-116-100.ams2.redhat.com [10.36.116.100]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s68ICEk0026523; Tue, 8 Jul 2014 14:12:14 -0400 Subject: Re: [PATCH 2/2] Emit DW_tag_restrict_type for restrict-qualified pointers. From: Mark Wielaard To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Cary Coutant , "Joseph S. Myers" In-Reply-To: <1404837544-32127-2-git-send-email-mjw@redhat.com> References: <1403305305-29532-1-git-send-email-mjw@redhat.com> <1404837544-32127-2-git-send-email-mjw@redhat.com> Date: Tue, 08 Jul 2014 20:12:13 +0200 Message-ID: <1404843133.4117.2.camel@bordewijk.wildebeest.org> Mime-Version: 1.0 Forgot to rebase my ChangeLog, sorry. Here is the version with the correct one: gcc/ChangeLog PR debug/59051 * dwarf2out.h (modified_type_die): Handle TYPE_QUAL_RESTRICT. gcc/testsuite/ChangeLog PR debug/59051 * gcc.dg/guality/restrict.c: New test. --- gcc/ChangeLog | 5 +++ gcc/dwarf2out.c | 33 ++++++++++++++++----- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/guality/restrict.c | 48 +++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/guality/restrict.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3f63f1b..339f368 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-07-08 Mark Wielaard + + PR debug/59051 + * dwarf2out.c (modified_type_die): Handle TYPE_QUAL_RESTRICT. + 2014-07-07 Mark Wielaard * dwarf2out.c (decl_quals): New function. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 068bbc3..be17cad 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -10522,7 +10522,13 @@ modified_type_die (tree type, int cv_quals, dw_die_ref context_die) return NULL; /* Only these cv-qualifiers are currently handled. */ - cv_quals &= (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); + cv_quals &= (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT); + + /* Don't emit DW_TAG_restrict_type for DWARFv2, since it is a type + tag modifier (and not an attribute) old consumers won't be able + to handle it. */ + if (dwarf_version < 3) + cv_quals &= ~TYPE_QUAL_RESTRICT; /* See if we already have the appropriately qualified variant of this type. */ @@ -10567,7 +10573,7 @@ modified_type_die (tree type, int cv_quals, dw_die_ref context_die) else { int dquals = TYPE_QUALS_NO_ADDR_SPACE (dtype); - dquals &= (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); + dquals &= (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT); if ((dquals & ~cv_quals) != TYPE_UNQUALIFIED || (cv_quals == dquals && DECL_ORIGINAL_TYPE (name) != type)) /* cv-unqualified version of named type. Just use @@ -10581,22 +10587,33 @@ modified_type_die (tree type, int cv_quals, dw_die_ref context_die) mod_scope = scope_die_for (type, context_die); if ((cv_quals & TYPE_QUAL_CONST) - /* If both const_type and volatile_type, prefer the path - which leads to a qualified type. */ - && (!(cv_quals & TYPE_QUAL_VOLATILE) - || get_qualified_type (type, TYPE_QUAL_CONST) == NULL_TREE - || get_qualified_type (type, TYPE_QUAL_VOLATILE) != NULL_TREE)) + /* If there are multiple type modifiers, prefer a path which + leads to a qualified type. */ + && (((cv_quals & ~TYPE_QUAL_CONST) == TYPE_UNQUALIFIED) + || get_qualified_type (type, cv_quals) == NULL_TREE + || (get_qualified_type (type, cv_quals & ~TYPE_QUAL_CONST) + != NULL_TREE))) { mod_type_die = new_die (DW_TAG_const_type, mod_scope, type); sub_die = modified_type_die (type, cv_quals & ~TYPE_QUAL_CONST, context_die); } - else if (cv_quals & TYPE_QUAL_VOLATILE) + else if ((cv_quals & TYPE_QUAL_VOLATILE) + && (((cv_quals & ~TYPE_QUAL_VOLATILE) == TYPE_UNQUALIFIED) + || get_qualified_type (type, cv_quals) == NULL_TREE + || (get_qualified_type (type, cv_quals & ~TYPE_QUAL_VOLATILE) + != NULL_TREE))) { mod_type_die = new_die (DW_TAG_volatile_type, mod_scope, type); sub_die = modified_type_die (type, cv_quals & ~TYPE_QUAL_VOLATILE, context_die); } + else if (cv_quals & TYPE_QUAL_RESTRICT) + { + mod_type_die = new_die (DW_TAG_restrict_type, mod_scope, type); + sub_die = modified_type_die (type, cv_quals & ~TYPE_QUAL_RESTRICT, + context_die); + } else if (code == POINTER_TYPE) { mod_type_die = new_die (DW_TAG_pointer_type, mod_scope, type); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1abc700..184ca67 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-07-08 Mark Wielaard + + PR debug/59051 + * gcc.dg/guality/restrict.c: New test. + 2014-07-03 Mark Wielaard * lib/gcc-gdb-test.exp (gdb-test): Handle type:var for gdb ptype diff --git a/gcc/testsuite/gcc.dg/guality/restrict.c b/gcc/testsuite/gcc.dg/guality/restrict.c new file mode 100644 index 0000000..e31224b --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/restrict.c @@ -0,0 +1,48 @@ +/* debuginfo tests for combinations of const, volatile, restrict pointers. */ +/* { dg-do run } */ +/* { dg-options "-std=c99 -gdwarf-3" } */ + +int *ip; +const int *cip; +int * restrict irp; +int * const icp; +const int * restrict cirp; +int * const restrict icrp; +const int * const restrict cicrp; + +int * const volatile restrict cvirp; +const volatile int * restrict pcvir; + +static __attribute__((noclone, noinline)) void * +cpy (void * restrict s1, const void * restrict s2, unsigned int n) +{ + char *t1 = s1; + const char *t2 = s2; + while(n-- > 0) + *t1++ = *t2++; + return s1; +} + +int +main (int argc, char **argv) +{ + void *foo = 0; + if (argc > 16) + foo = cpy (argv[0], argv[1], argc); + + return foo != 0; +} + +/* { dg-final { gdb-test 30 "type:ip" "int *" } } */ +/* { dg-final { gdb-test 30 "type:cip" "const int *" } } */ +/* { dg-final { gdb-test 30 "type:irp" "int * restrict" } } */ +/* { dg-final { gdb-test 30 "type:icp" "int * const" } } */ +/* { dg-final { gdb-test 30 "type:cirp" "const int * restrict" } } */ +/* { dg-final { gdb-test 30 "type:icrp" "int * const restrict" } } */ +/* { dg-final { gdb-test 30 "type:cicrp" "const int * const restrict" } } */ + +/* { dg-final { gdb-test 30 "type:cvirp" "int * const volatile restrict" } } */ +/* { dg-final { gdb-test 30 "type:pcvir" "const volatile int * restrict" } } */ + +/* { dg-final { gdb-test 30 "type:main" "int (int, char **)" } } */ +/* { dg-final { gdb-test 30 "type:cpy" "void *(void * restrict, const void * restrict, unsigned int)" } } */