From patchwork Sun Mar 23 11:15:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 332879 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 4EDBD2C00C3 for ; Sun, 23 Mar 2014 22:16:05 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=QUJhiZBTqVQe4fWV7LhGiJ2n9U4/aOJs2+MDxBdI0R5loh5bZWx4h zyV51J6pBt0cuBqP0gqO2HNDWeZmZ+02tLAgG7FTMnJXRfAeD5ZwLf7hr6vPVoqK X/VveAJbSxZcZ6ryFSqMgkQ5Qa3g1sw76Mu7z4ZyrQA7OkyH5sVt0E= 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:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=05RV/PS7qK4zdLEHIjNm3GBEGlw=; b=IC5H5r6KNY22C8cQx115 xhHyBxr9nSTGlaMp/yYHjD6hxZVd8Yzr+v/DTJVTxHBOafdxOJqwA09Ls9ZGtFTT BUWt10wJEnm1DlSV3AGrJLyDIMPROsUfRTyrUiwUkKgVftO1PURj4EK1iX1ICLuo 3Xw2XPAQmdiMH/wBjEHy6zE= Received: (qmail 24419 invoked by alias); 23 Mar 2014 11:15:56 -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 24395 invoked by uid 89); 23 Mar 2014 11:15:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sun, 23 Mar 2014 11:15:51 +0000 From: Mark Wielaard To: gcc-patches@gcc.gnu.org Cc: Mark Wielaard Subject: [PATCH] dwarf2out: Use normal constant values in bound_info if possible. Date: Sun, 23 Mar 2014 12:15:09 +0100 Message-Id: <1395573309-21016-1-git-send-email-mjw@redhat.com> In-Reply-To: <20140323085436.GA3372@toonder.wildebeest.org> References: <20140323085436.GA3372@toonder.wildebeest.org> X-Spam-Score: -2.9 (--) * dwarf2out.c (add_bound_info): If HOST_WIDE_INT is big enough, then represent the bound as normal constant value. --- gcc/ChangeLog | 5 +++++ gcc/dwarf2out.c | 32 ++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3ab789a..8a31187 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-03-20 Mark Wielaard + + * dwarf2out.c (add_bound_info): If HOST_WIDE_INT is big enough, + then represent the bound as normal constant value. + 2014-03-19 Marek Polacek PR sanitizer/60569 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 2b584a5..9f8b3b0 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -16198,21 +16198,29 @@ add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr, tree b && tree_to_shwi (bound) == dflt) ; - /* Otherwise represent the bound as an unsigned value with the - precision of its type. The precision and signedness of the - type will be necessary to re-interpret it unambiguously. */ - else if (prec < HOST_BITS_PER_WIDE_INT) + /* If HOST_WIDE_INT is big enough then represent the bound as + a constant value. Note that we need to make sure the type + is signed or unsigned. We cannot just add an unsigned + constant if the value itself is positive. Some DWARF + consumers will lookup the bounds type and then sign extend + any unsigned values found for signed types. This is only + for DW_AT_lower_bound, normally unsigned values + (DW_FORM_data[1248]) are assumed to not need + sign-extension. */ + else if (prec <= HOST_BITS_PER_WIDE_INT + || TREE_INT_CST_HIGH (bound) == 0) { - unsigned HOST_WIDE_INT mask - = ((unsigned HOST_WIDE_INT) 1 << prec) - 1; - add_AT_unsigned (subrange_die, bound_attr, - TREE_INT_CST_LOW (bound) & mask); + if (TYPE_UNSIGNED (TREE_TYPE (bound))) + add_AT_unsigned (subrange_die, bound_attr, + TREE_INT_CST_LOW (bound)); + else + add_AT_int (subrange_die, bound_attr, TREE_INT_CST_LOW (bound)); } - else if (prec == HOST_BITS_PER_WIDE_INT - || TREE_INT_CST_HIGH (bound) == 0) - add_AT_unsigned (subrange_die, bound_attr, - TREE_INT_CST_LOW (bound)); else + /* Otherwise represent the bound as an unsigned value with + the precision of its type. The precision and signedness + of the type will be necessary to re-interpret it + unambiguously. */ add_AT_double (subrange_die, bound_attr, TREE_INT_CST_HIGH (bound), TREE_INT_CST_LOW (bound)); }