From patchwork Wed Oct 7 14:00:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1378030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=jYL73XrQ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C5wwf0HCtz9sSf for ; Thu, 8 Oct 2020 01:01:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D919D393C86B; Wed, 7 Oct 2020 14:01:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D919D393C86B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1602079260; bh=k7h+Dh10DsjKoxNDsDgnn2pmZgKGubhWIMOX5LhNkPw=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=jYL73XrQI87PrXqArL2uCg0462y+TChGI9Jvyo4Wcx2SM0KCtIfZ1MREtR44TnGdu Pru5L/mQJbya0kBDkiL/rNXkJgGeFOKHjj4dpfSUVCnYBiKMd56PsnOy0uWXMO4bcQ c36P8tqPBXspu3ZP7TWdJFo9KnmnbERaZgM4SiWk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id EAA72381DCE9 for ; Wed, 7 Oct 2020 14:00:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EAA72381DCE9 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-484-SXlAMHBON4q0SX-KM28vrA-1; Wed, 07 Oct 2020 10:00:52 -0400 X-MC-Unique: SXlAMHBON4q0SX-KM28vrA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D55F1054F90 for ; Wed, 7 Oct 2020 14:00:50 +0000 (UTC) Received: from [10.10.118.179] (ovpn-118-179.rdu2.redhat.com [10.10.118.179]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DD335D9F1 for ; Wed, 7 Oct 2020 14:00:49 +0000 (UTC) Subject: [PUSHED] Off by one final fix. To: gcc-patches@gcc.gnu.org References: <1b738b59-9b9f-c796-8271-c0f3ddbb2e90@redhat.com> <20201006075250.GX2176@tucnak> <6190773d-534e-56b0-f8e2-4a05cbf898cd@gmail.com> <20201006173230.GH2176@tucnak> <2fb1b830-35a4-42f8-3037-99c7a2518be1@redhat.com> <20201006174832.GI2176@tucnak> <9f0c0c4a-6098-cd24-f1fa-e4c8bce31c7d@redhat.com> <87a6wzjiyk.fsf@igel.home> Message-ID: <3e6ab53f-7d14-c0c7-f0ac-e36188fbf907@redhat.com> Date: Wed, 7 Oct 2020 10:00:49 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" On 10/6/20 2:59 PM, Andrew MacLeod via Gcc-patches wrote: > On 10/6/20 2:41 PM, Andreas Schwab wrote: >> On Okt 06 2020, Andrew MacLeod via Gcc-patches wrote: >> >>> diff --git a/gcc/value-range.h b/gcc/value-range.h >>> index 7031a823138..02a952bf81f 100644 >>> --- a/gcc/value-range.h >>> +++ b/gcc/value-range.h >>> @@ -668,13 +668,12 @@ irange_allocator::allocate (unsigned num_pairs) >>>     if (num_pairs < 2) >>>       num_pairs = 2; >>>   -  struct newir { >>> -    irange range; >>> -    tree mem[2]; >>> -  }; >>> -  size_t nbytes = (sizeof (newir) + sizeof (tree) * 2 * (num_pairs >>> - 1)); >>> -  struct newir *r = (newir *) obstack_alloc (&m_obstack, nbytes); >>> -  return new (r) irange (r->mem, num_pairs); >>> +  size_t nbytes = sizeof (tree) * 2 * num_pairs; >>> + >>> +  // Allocate the irnge and  required memory for the vector >> Typo: irange >> >> Andreas. >> > Ha. Its all good now.     THIS is actually the final final FINAL patch > which is going thru testing. > > And its now in. 2020-10-06 Andrew MacLeod * value-range.h (irange_allocator::allocate): Allocate in two hunks instead of using the variably-sized trailing array approach. diff --git a/gcc/value-range.h b/gcc/value-range.h index 7031a823138..63c96204cda 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -668,13 +668,12 @@ irange_allocator::allocate (unsigned num_pairs) if (num_pairs < 2) num_pairs = 2; - struct newir { - irange range; - tree mem[2]; - }; - size_t nbytes = (sizeof (newir) + sizeof (tree) * 2 * (num_pairs - 1)); - struct newir *r = (newir *) obstack_alloc (&m_obstack, nbytes); - return new (r) irange (r->mem, num_pairs); + size_t nbytes = sizeof (tree) * 2 * num_pairs; + + // Allocate the irange and required memory for the vector. + void *r = obstack_alloc (&m_obstack, sizeof (irange)); + tree *mem = (tree *) obstack_alloc (&m_obstack, nbytes); + return new (r) irange (mem, num_pairs); } inline irange *