From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127010 invoked by alias); 12 Jul 2019 07:49:01 -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 127002 invoked by uid 89); 12 Jul 2019 07:49:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Jul 2019 07:49:00 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E4C4337 for ; Fri, 12 Jul 2019 00:48:58 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 320B83F59C for ; Fri, 12 Jul 2019 00:48:58 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Relax vector_builder::elt sanity check Date: Fri, 12 Jul 2019 07:55:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2019-07/txt/msg00930.txt.bz2 I'd made it a precondition of vector_builder::elt that the encoding must have been fully populated and that all implicit elements are therefore defined. But for one of the AArch64 patches I'm working on, it'd be convenient to be able to look back at previous elements while building up the encoding. This patch therefore makes the assert specific to implicit elements only. Tested on aarch64-linux-gnu, aarch64_be-elf and x86_64-linux-gnu. OK to install? Richard 2019-07-12 Richard Sandiford gcc/ * vector-builder.h (vector_builder::elt): Allow already-supplied elements to be read back before building is complete. Index: gcc/vector-builder.h =================================================================== --- gcc/vector-builder.h 2019-07-12 08:39:56.000000000 +0100 +++ gcc/vector-builder.h 2019-07-12 08:46:38.069172474 +0100 @@ -199,14 +199,15 @@ vector_builder::operator == T vector_builder::elt (unsigned int i) const { - /* This only makes sense if the encoding has been fully populated. */ - gcc_checking_assert (encoded_nelts () <= this->length ()); - /* First handle elements that are already present in the underlying vector, regardless of whether they're part of the encoding or not. */ if (i < this->length ()) return (*this)[i]; + /* Extrapolation is only possible if the encoding has been fully + populated. */ + gcc_checking_assert (encoded_nelts () <= this->length ()); + /* Identify the pattern that contains element I and work out the index of the last encoded element for that pattern. */ unsigned int pattern = i % m_npatterns;