From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 17:24:00 -0000 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 Content-Type: text/plain X-SW-Source: 2017-10/txt/msg01559.txt.bz2 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