From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121798 invoked by alias); 8 Aug 2016 17:00:32 -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 121785 invoked by uid 89); 8 Aug 2016 17:00:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=principles, strcat, shorter 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; Mon, 08 Aug 2016 17:00:30 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 05C16285C8; Mon, 8 Aug 2016 17:00:29 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-190.phx2.redhat.com [10.3.116.190]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u78H0SZA027987; Mon, 8 Aug 2016 13:00:28 -0400 Subject: Re: protected alloca class for malloc fallback To: Richard Biener , Aldy Hernandez , Oleg Endo , Martin Sebor , gcc-patches References: <57A32741.7010003@redhat.com> <57A3F57F.3050509@gmail.com> <57A4A5E8.90205@redhat.com> <1470420954.639.64.camel@t-online.de> <44EE0FB0-A8B9-43F9-BF58-C4D7D27DA944@gmail.com> <57A5B8BE.2000004@redhat.com> <941D179C-146F-4004-BECB-9FB066DDCC8D@gmail.com> From: Jeff Law Message-ID: <21bcbebe-28a8-58a7-68e8-af9abcb03dce@redhat.com> Date: Mon, 08 Aug 2016 17:00: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: <941D179C-146F-4004-BECB-9FB066DDCC8D@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-08/txt/msg00611.txt.bz2 On 08/06/2016 09:08 AM, Richard Biener wrote: > On August 6, 2016 12:15:26 PM GMT+02:00, Aldy Hernandez wrote: >> On 08/05/2016 04:07 PM, Richard Biener wrote: >>> On August 5, 2016 8:15:54 PM GMT+02:00, Oleg Endo >> wrote: >>>> On Fri, 2016-08-05 at 19:55 +0200, Richard Biener wrote: >>>> >>>>> >>>>> Please don't use std::string. For string building you can use >>>>> obstacks. >>>>> >>>> >>>> Just out of curiosity ... why? I remember there was some discussion >>>> about it, what was the conclusion? Is that now a general rule or >> does >>>> it depend on the context where strings are used? >>> >>> Because you make a messy mix of string handling variants. >> Std::string is not powerful enough to capture all uses, it is vastly >> more expensive to embed into structs and it pulls in too much headers. >>> (Oh, and I hate I/o streams even more) >> >> Oh, and there is prior use in ipa-chkp.c, although I suppose it >> could've >> crept in: > > Definitely. > >> >> std::string s; >> >> /* called_as_built_in checks DECL_NAME to identify calls to >> builtins. We want instrumented calls to builtins to be >> recognized by called_as_built_in. Therefore use original >> DECL_NAME for cloning with no prefixes. */ >> s = IDENTIFIER_POINTER (DECL_NAME (fndecl)); >> s += ".chkp"; >> DECL_NAME (new_decl) = get_identifier (s.c_str ()); >> >> You can't tell me obstacks are easier on the eyes for this ;-). > > Even strcat is shorter and cheaper. ISTM that unless the code is performance critical we should be writing code that is easy to understand and hard to get wrong. Thus when we have something that is non-critical and can be handled by std:: routines we should be using them. If performance is important in a particular piece of code an obstack or explicit malloc/free seems better. Can we agree on those as guiding principles and thus boil the argument down to whether or not a particular piece of code is performance critical? jeff