From owner-svn-src-all@freebsd.org Wed Jun 17 10:20:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8401D34A15D; Wed, 17 Jun 2020 10:20:24 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49n1Kg4CGcz4ZYg; Wed, 17 Jun 2020 10:20:23 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: by mail-ej1-f41.google.com with SMTP id l12so1700189ejn.10; Wed, 17 Jun 2020 03:20:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XUb2lUkzxqfGiO9QMycj6rNs8YikUGUK4sb/u/Rs538=; b=sLKaEBvT90i9UwVe+v8QIlSjkbrlAKDHrxoHjw6O/wjfrII0wksbAtZ1tdVdiUVGkp 15XlshWqaCsDZRu2xNquw1DR12jPdm2dWlC4cw67D3vM03F35Mg70m8dZ+U96vYM+Cfu Xi55mQ+lSM2w2aiegFhgwA/xAOMnFzLKKACFXcOWf9URZuH8pRPawF7j63N65gwqYr+X yiSvXM89QZDatmmluYATbPXC+m9/fGWGQ5QlnfBl9QEJcqI1gWr3+ymXSBpY57iFOxWI Ka8/LX5kMRCt/3f3Zr4SfnO7XEjS0g4NBv4BKLJqUbaNRhe3ffcffxiYn/2pDMe39Ri7 Ltgw== X-Gm-Message-State: AOAM5320+bp8NnCp0GS+4IZThb6ChRsUupAbSTQIAnijZXad6/3AWFR+ 0QhdWMHs4uF6JZmCMc2WXU698lXD+ewT4Q== X-Google-Smtp-Source: ABdhPJyGIKgogHTK0Av5NTQQJQwCguXQxDpPt7ZcMeKh1+dAfg+ifNZ2Qoyqmk7Gn9GfBYLuyPaA7g== X-Received: by 2002:a17:906:468e:: with SMTP id a14mr6796710ejr.124.1592389221511; Wed, 17 Jun 2020 03:20:21 -0700 (PDT) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id q14sm11707170edj.47.2020.06.17.03.20.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jun 2020 03:20:21 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id q11so1739548wrp.3; Wed, 17 Jun 2020 03:20:20 -0700 (PDT) X-Received: by 2002:a5d:630f:: with SMTP id i15mr7554208wru.309.1592389220650; Wed, 17 Jun 2020 03:20:20 -0700 (PDT) MIME-Version: 1.0 References: <202006160705.05G753T4057972@repo.freebsd.org> <55903c38d363aef2a6f6d0075dd4526b86d51258.camel@freebsd.org> <202006161708.05GH8ibS019561@slippy.cwsent.com> In-Reply-To: <202006161708.05GH8ibS019561@slippy.cwsent.com> From: Alexander Richardson Date: Wed, 17 Jun 2020 11:20:09 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r362217 - head/stand/common To: Cy Schubert Cc: Ian Lepore , Toomas Soome , src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 49n1Kg4CGcz4ZYg X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of arichardsonkde@gmail.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=arichardsonkde@gmail.com X-Spamd-Result: default: False [-2.31 / 15.00]; ARC_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[209.85.218.41:from]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; NEURAL_HAM_LONG(-0.90)[-0.896]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.79)[-0.789]; RCVD_IN_DNSWL_NONE(0.00)[209.85.218.41:from]; NEURAL_HAM_MEDIUM(-0.62)[-0.623]; FORGED_SENDER(0.30)[arichardson@freebsd.org,arichardsonkde@gmail.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[arichardson@freebsd.org,arichardsonkde@gmail.com] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 10:20:24 -0000 On Tue, 16 Jun 2020 at 18:09, Cy Schubert wrote: > > In message <55903c38d363aef2a6f6d0075dd4526b86d51258.camel@freebsd.org>, > Ian Le > pore writes: > > On Tue, 2020-06-16 at 07:05 +0000, Toomas Soome wrote: > > > Author: tsoome > > > Date: Tue Jun 16 07:05:03 2020 > > > New Revision: 362217 > > > URL: https://svnweb.freebsd.org/changeset/base/362217 > > > > > > Log: > > > loader: variable i is unused without MBR/GPT support built in > > > > > > Because i is only used as index in for loop, declare it in for > > > statement. > > > > > > > As much as I prefer doing it this way, style(9) doesn't allow for > > variable declarations inside a for() statement (or even inside a local > > block, which is just too 1980s for me, but it is still our standard). > > Doesn't this use stack for a shorter period of time or does the compiler > optimize this, making this change moot? > > The tradeoff is a few extra bytes of stack for a longer period of time vs a > few extra instructions incrementing and decrementing the stack pointer. > > At least for LLVM it makes no difference where you declare the variable: it will always be represented by an alloca instruction at the start of the IR function: https://godbolt.org/z/NFG3hN There will also not be any changes to the stack pointer since the stack frame size is fixed no matter where the variables are declared (unless you use variable-length arrays or __builtin_alloca()). LLVM will also merge variables that have non-overlapping lifetimes to reuse the same stack slot if possible. I'm almost certain GCC performs the same optimizations (as will any other compiler written in the last 20 years). Alex