From patchwork Tue Jul 27 09:21:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 59983 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 3506DB6EFF for ; Tue, 27 Jul 2010 19:19:25 +1000 (EST) Received: (qmail 11262 invoked by alias); 27 Jul 2010 09:19:24 -0000 Received: (qmail 11251 invoked by uid 22791); 27 Jul 2010 09:19:23 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, 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, 27 Jul 2010 09:19:16 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6R9JFJ9023309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 27 Jul 2010 05:19:15 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6R9JEEa007852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Jul 2010 05:19:15 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o6R9Lbrt004180; Tue, 27 Jul 2010 11:21:37 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o6R9LblZ004178; Tue, 27 Jul 2010 11:21:37 +0200 Date: Tue, 27 Jul 2010 11:21:37 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Roland McGrath , Tom Tromey Subject: [PATCH] Use slightly more compact DW_AT_data_member_location Message-ID: <20100727092137.GV18378@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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! E.g. on struct A { char pad[136]; int i; } a; the following patch saves one byte in .debug_info, by using DW_FORM_data1 instead of DW_FORM_sdata for DW_AT_data_member_location. I've briefly looked at gdb (and valgrind) and I think it should handle this just fine: xxx = dwarf2_get_attr_constant_value (attr, 0); and if (attr->form == DW_FORM_sdata) return DW_SND (attr); else if (attr->form == DW_FORM_udata || attr->form == DW_FORM_data1 || attr->form == DW_FORM_data2 || attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8) return DW_UNSND (attr); Ok for trunk? 2010-07-27 Jakub Jelinek * dwarf2out.c (add_data_member_location_attribute): Use add_AT_unsigned instead of add_AT_int if offset is non-negative. Jakub --- gcc/dwarf2out.c.jj 2010-07-26 11:40:20.000000000 +0200 +++ gcc/dwarf2out.c 2010-07-27 11:08:38.000000000 +0200 @@ -15911,7 +15911,10 @@ add_data_member_location_attribute (dw_d if (dwarf_version > 2) { /* Don't need to output a location expression, just the constant. */ - add_AT_int (die, DW_AT_data_member_location, offset); + if (offset < 0) + add_AT_int (die, DW_AT_data_member_location, offset); + else + add_AT_unsigned (die, DW_AT_data_member_location, offset); return; } else