From owner-freebsd-hackers@FreeBSD.ORG Fri May 1 21:03:29 2009 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8B9451065674 for ; Fri, 1 May 2009 21:03:29 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id E10B78FC16 for ; Fri, 1 May 2009 21:03:28 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: (qmail invoked by alias); 01 May 2009 21:03:27 -0000 Received: from p54A3F073.dip.t-dialin.net (EHLO tron.homeunix.org) [84.163.240.115] by mail.gmx.net (mp056) with SMTP; 01 May 2009 23:03:27 +0200 X-Authenticated: #1673122 X-Provags-ID: V01U2FsdGVkX1+ND+pFSluNt3eDUHeLiZxWyAMnEDFv5tRGqh252F u1/x5JpK7E/5y+ Message-ID: <49FB639E.9020401@gmx.de> Date: Fri, 01 May 2009 23:03:26 +0200 From: Christoph Mallon User-Agent: Thunderbird 2.0.0.21 (X11/20090412) MIME-Version: 1.0 To: "M. Warner Losh" References: <20090428114754.GB89235@server.vk2pj.dyndns.org> <20090430.090226.1569754707.imp@bsdimp.com> <49FA8D73.6040207@gmx.de> <20090501.080927.-1923761682.imp@bsdimp.com> In-Reply-To: <20090501.080927.-1923761682.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.54 Cc: freebsd-hackers@FreeBSD.org Subject: Re: C99: Suggestions for style(9) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2009 21:03:29 -0000 M. Warner Losh schrieb: > In message: <49FA8D73.6040207@gmx.de> > Christoph Mallon writes: > : M. Warner Losh schrieb: > : > In message: <20090428114754.GB89235@server.vk2pj.dyndns.org> > : > Peter Jeremy writes: > : > : >> +.Sh LOCAL VARIABLES > : > : > : > : >Last, but definitely not least, I added this paragraph about the use of > : > : >local variables. This is to clarify, how today's compilers handle > : > : >unaliased local variables. > : > : > : > : Every version of gcc that FreeBSD has ever used would do this for > : > : primitive types when optimisation was enabled. This approach can > : > : become expensive in stack (and this is an issue for kernel code) when > : > : using non-primitive types or when optimisation is not enabled (though > : > : I'm not sure if this is supported). Assuming that gcc (and icc and > : > : clang) behaves as stated in all supported optimisation modes, this > : > : change would appear to be quite safe to make. > : > > : > Agreed, in general. We don't want to optimize our code style based on > : > what one compiler does, perhaps on x86. > : > : I'm not sure whether I understand this - in particular the last three words. > > I'm saying we shouldn't tune our coding standard to the optimizations > that the compiler of the hour gives, especially if those optimizations > to the style are tuned to one architecture. Since there's little > evidence presented on how these style changes will help any > architecture, it is hard to judge if this is the case or not. The main goal of the proposed change is not about optimisation, but about clarity of the code: It is better to declare multiple variables with meaningful names instead of having one generic "int k;" used in several different contexts. I just also mentioned, that re-using variables in different contexts when taking its address is involved, leads to worse machine code, but this is a minor point. It's just that clarity for a reader and quality of the generated code nicely correlate here. Christoph