From patchwork Mon Oct 23 17:24:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116803 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4889432qgn; Mon, 23 Oct 2017 10:24:57 -0700 (PDT) X-Received: by 10.98.7.210 with SMTP id 79mr13594003pfh.252.1508779497503; Mon, 23 Oct 2017 10:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508779497; cv=none; d=google.com; s=arc-20160816; b=uIpDbx49W2s8X663TwVjLVvrzMs3qZgzetwhWJq6/JEDTJ04yTS4Q/1zZzH5sDq7QH E2pJUO7hLbxM7i7vAwes3qG8UbaG7/X6ybEKwLg8qCLPqs+Mrhx0pmcBrvu2xpvwbDEi Be1KO41PRmT5IIQEDuxucOk1vsA/4koEdYuAInS9B7MD5/Q+h26Qsl0kKrAaxQo+RDoF 23FsiOSRhokpl7E2aL2YSKLkfByCLO45HEPcZhZfoBzjmXkRVIDr64DWmMtEwAM5mSGK q6S+lXPQE3V2cZ0VXYrNMePgpDcrKVjRZUXH+uzHf754G/uCwF1inpQN4jronPbgg8fx 2E0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=TmoORK4ADL5EMR4DR74Y+21pjJDzNQw4HV+HA89lWXA=; b=eL2ItYx/uRhwIbF5+cD2ZC+6zPdd7D7h9mmR3KDujXR7qUUO/+8k219yNiNp46OFk9 ++7Yh+1Svu8gpknLG00UwOQcXDD0UElHLF8wVPE82rpVWXW3hspkkSiKD1mpshC/KSOe FGY88bW9SXgaOdGpMViKngL3zMiScqfDEufvPtMQGCF/lJaQv8JDC7JD3+e79dCuG6WL kmSwYOK/cCnVc+h5Jrua9vSKh7BlCsQujWLsCxizkrTK3DIi5zC38NaKhyEG3ZpLDiRS zncwe7wDWSR2A0l0DOtz9DBr8BV3fkwpCAo85D772fVVhBaLGPaNCg8NiCI5zj6Ipfi2 CocQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=i/TJxFEQ; spf=pass (google.com: domain of gcc-patches-return-464834-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464834-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y7si45658pgb.829.2017.10.23.10.24.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464834-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=i/TJxFEQ; spf=pass (google.com: domain of gcc-patches-return-464834-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464834-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=a7wNO5rAtdQWGkwwJw6WWicw0xJY2 76Am+RyurQzY5RtpUVgAhYRdxhTc2n1MUFUci9fIOcyt83r/LJ4314qfgbemKikN 0yqEyOxKbpjPEOv/ctxI3Hb8bW/S/WpxLR5Ka/+r92sLyzSKwJfRPWg6KUzmWga8 pCyGiI1+75H4+A= 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=TBGOeMj9IQsu+av8NNs/1hXy0ek=; b=i/T JxFEQi55qDRZhy+4hYq6AjS9cDGOoPQszgS1HvCIcjn/6DWzRtwGToA4a6TXXOKx Oc1BfILsJrKM5oio9SWRkS7B9aOsM7/6ftLV8wWMyXunsKqoTUk+RxF4nOGRLcCT Y1NgfReZukbpbPl/GOQQodEvC8QsliyRT2TuBlYY= Received: (qmail 58123 invoked by alias); 23 Oct 2017 17:24:42 -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 57912 invoked by uid 89); 23 Oct 2017 17:24:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=123587 X-HELO: mail-wr0-f182.google.com Received: from mail-wr0-f182.google.com (HELO mail-wr0-f182.google.com) (209.85.128.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:24:23 +0000 Received: by mail-wr0-f182.google.com with SMTP id j15so6025145wre.8 for ; Mon, 23 Oct 2017 10:24:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=TmoORK4ADL5EMR4DR74Y+21pjJDzNQw4HV+HA89lWXA=; b=exiBtEqMmXmO3GAdDHSd8bEhy9sJA7cu2dsXdTymMQufNLoLcwNbmJg0S3iGRlB+dn qP4FkN0yi13VsVecTwOw598t4iSGyg5ZL9n2I5F6gX7EwYas1cxbzBwaZgdct7f69zQJ pdlMRIFJ2SZ6wcVQfvo+0Yx1rl5ejkv/5Ld4L0V+spdbnjaHGJEkBTN5DRusfuCprOuC WtXY0H6qS/2mAg4gyEcz7KUEVJCxPBE0U0Apq5WOOlGZLwJTXxT4fg2MS6VV5kR29V1u FVW2kAqAq/tXdtytObZHG0jKGxBpB/JYsxN+iWyTUEwvX7mMAsGFa5XGaz3B03fcbwjB llAw== X-Gm-Message-State: AMCzsaVTLvjEFQQNWoPJ3+fynf0zlYhXPgpZyxsUk7jDV+fGRS9IYY9Y YbelJsdVvwjQUF6+u3vGKrOgLfieKVk= X-Google-Smtp-Source: ABhQp+SXPu35qM8hVYTkUPHtAiIrwX08GdC0z3YiHA6MOC0VMXbN5bw2zRiqveNz5ePhAKrEjC31vg== X-Received: by 10.223.188.147 with SMTP id g19mr12713932wrh.250.1508779461496; Mon, 23 Oct 2017 10:24:21 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id 29sm7867353wrz.77.2017.10.23.10.24.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:24:20 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [058/nnn] poly_int: get_binfo_at_offset References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:24:20 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87wp3lkcaj.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch changes the offset parameter to get_binfo_at_offset from HOST_WIDE_INT to poly_int64. This function probably doesn't need to handle polynomial offsets in practice, but it's easy to do and avoids forcing the caller to check first. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree.h (get_binfo_at_offset): Take the offset as a poly_int64 rather than a HOST_WIDE_INT. * tree.c (get_binfo_at_offset): Likewise. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2017-10-23 17:20:50.884679814 +0100 +++ gcc/tree.h 2017-10-23 17:22:21.308442966 +0100 @@ -4836,7 +4836,7 @@ extern void tree_set_block (tree, tree); extern location_t *block_nonartificial_location (tree); extern location_t tree_nonartificial_location (tree); extern tree block_ultimate_origin (const_tree); -extern tree get_binfo_at_offset (tree, HOST_WIDE_INT, tree); +extern tree get_binfo_at_offset (tree, poly_int64, tree); extern bool virtual_method_call_p (const_tree); extern tree obj_type_ref_class (const_tree ref); extern bool types_same_for_odr (const_tree type1, const_tree type2, Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-10-23 17:22:18.236826658 +0100 +++ gcc/tree.c 2017-10-23 17:22:21.307442765 +0100 @@ -12328,7 +12328,7 @@ lookup_binfo_at_offset (tree binfo, tree found, return, otherwise return NULL_TREE. */ tree -get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type) +get_binfo_at_offset (tree binfo, poly_int64 offset, tree expected_type) { tree type = BINFO_TYPE (binfo); @@ -12340,7 +12340,7 @@ get_binfo_at_offset (tree binfo, HOST_WI if (types_same_for_odr (type, expected_type)) return binfo; - if (offset < 0) + if (may_lt (offset, 0)) return NULL_TREE; for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld)) @@ -12350,7 +12350,7 @@ get_binfo_at_offset (tree binfo, HOST_WI pos = int_bit_position (fld); size = tree_to_uhwi (DECL_SIZE (fld)); - if (pos <= offset && (pos + size) > offset) + if (known_in_range_p (offset, pos, size)) break; } if (!fld || TREE_CODE (TREE_TYPE (fld)) != RECORD_TYPE) @@ -12358,7 +12358,7 @@ get_binfo_at_offset (tree binfo, HOST_WI /* Offset 0 indicates the primary base, whose vtable contents are represented in the binfo for the derived class. */ - else if (offset != 0) + else if (maybe_nonzero (offset)) { tree found_binfo = NULL, base_binfo; /* Offsets in BINFO are in bytes relative to the whole structure