From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106213 invoked by alias); 5 Aug 2016 16:23:31 -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 106203 invoked by uid 89); 5 Aug 2016 16:23:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 05 Aug 2016 16:23:30 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D95894A54A; Fri, 5 Aug 2016 16:23:28 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u75GNSB2010699; Fri, 5 Aug 2016 12:23:28 -0400 Subject: Re: protected alloca class for malloc fallback To: Aldy Hernandez , Richard Biener References: <57A32741.7010003@redhat.com> <57A35CF6.1040504@redhat.com> <87147ff6-0133-0ba7-17ae-980fe425bf57@redhat.com> <57A4A4B9.9090908@redhat.com> Cc: gcc-patches , Pedro Alves From: Jeff Law Message-ID: <082fc386-345c-efa1-e1cd-053b1aa989a3@redhat.com> Date: Fri, 05 Aug 2016 16:23:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <57A4A4B9.9090908@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-08/txt/msg00479.txt.bz2 On 08/05/2016 08:37 AM, Aldy Hernandez wrote: > > After looking at all this code, I realize no size will fit all if we > want something clean. So, I take my approach back. I think we're best > served by a couple different approaches, depending on usage. Yup. > > My question is, how wed are we to an alloca based approach? Can we > replace the non-critical uses by std::string (diagnostics, > BLAH_check_failed(), building a string to manipulate the output of > env("SOME_VAR"), etc?). I don't think we are at all wed to alloca. > > Then for things like the GCC driver wanting to create a vector of passed > commands, we could use auto_vec<> (*gasp*, using a vector to represent a > vector ;-)). Note that auto_vec<> uses malloc (or GC) but creating a > malloc'd vector at startup is hardly on the fast path. > > For the remaining things we could use either alloca with a malloc > fallback for trivial things like set_user_assembler_name() that only > have one exit point, or take it on a case by case basis. > > But it seems to me that we can use an STL container for the non critical > things (which are the majority of them), and something else (perhaps an > RAII thinggie TBD later). > > Is this reasonable? I'd like to know before I spend any time converting > anything to std::string and auto_vec<>. Yes, this is all reasonable to me. I'm a big believer in moving towards standard library implementations of things. In this case we get to remove the allocas *and* make the code easier to grok for those that are familiar with the C++ standard library. Jeff