Received: by 10.213.65.68 with SMTP id h4csp2467993imn; Thu, 5 Apr 2018 15:54:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx48qWt9UU3T6MBNRX57FcJwsGifC4LkS+6JU+xNeBq5bAhOsGc4XlKFYkPJgDuIYkF4wospN X-Received: by 10.99.99.194 with SMTP id x185mr15898043pgb.4.1522968862062; Thu, 05 Apr 2018 15:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522968862; cv=none; d=google.com; s=arc-20160816; b=WX+bJH1NHB5YpqHzMl5clr7NDtJgSokihZwEwo+rJhcnIM0/Qv4gxOD1cQWvPey6u8 P2CuZVMpBa5JWNpv9qZDHwHyZQtaxOGmO8ZBX3yE9E9P2wp6R4vy5u5Krcp1855AWI/L J1QAUo9kxPaS8EUqax+3jLZMsJOEth6X5zcZe0iDUpm7KmP8iDDMSfNO4FDY1u1vePsV s5jFrXpIeqy5ZjrlkwMkyvDGwL4pQZ9LxMEaZ5+ZQBZL3Ce0QANz4Umvcg51m90lREs+ mp5ppXZ83gp6RWGFL/fWl9jFtdi0m7bf4Ejjq1BJaSypfIAZoc8riXm4yfA7xm9D996n TiGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=qE1M6AmQFjgNABMwGC/loA+R5NiFaqYwjUR90uESRFY=; b=oG9jXjRHLqySRaluleo5vnbWz50mC/g0oDBoaBpaYwPS6tdhZs6zQT3UmA9/xYTZ8s Hw7zZM+bIu5bHqe8iDMe8HKuNdV24Wpt/TebNrc8aRMPUTBvZltfsEauL5mXpMvLm+pa C/r5+SCTV93P7We9Lkzqr8TjNSuPRQ+kt0mqXHsIdH43EF9UaoADnteLRZZGlGZ2wuOq Qppk7dY4o42/UvgtF/TIuC8g3pDGvwjmbPowNqZG7I3gUOYgU9Sf1QtCXrH+NwjUjAwu cxiB1NUcQeQLHPL5lk5LcNE9aj18XzanlGrjFKgTIqOjXkjcI2cigcoEpYr6nMawSnQS 3fGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ebf/xPa+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z125si6947454pfz.335.2018.04.05.15.53.55; Thu, 05 Apr 2018 15:54:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ebf/xPa+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752662AbeDEWv7 (ORCPT + 99 others); Thu, 5 Apr 2018 18:51:59 -0400 Received: from mail-ua0-f195.google.com ([209.85.217.195]:40384 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750726AbeDEWv5 (ORCPT ); Thu, 5 Apr 2018 18:51:57 -0400 Received: by mail-ua0-f195.google.com with SMTP id n20so16503627ual.7 for ; Thu, 05 Apr 2018 15:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qE1M6AmQFjgNABMwGC/loA+R5NiFaqYwjUR90uESRFY=; b=ebf/xPa+S3xIkpxadV+Yrm6ZouXdLxoLue3ymnxGwcesLHbzhXwnE1LY31jfWVblb2 m4Q6AtxBh+WmM/1FAyd4zWIWhdw3vnAwO4rYrvum0Co6Hrs9+UgYCAO6wEKfGyjNCAMn v3pCBfbWGi09SiIjHkpTnv5kO3gi5Pfg5sDy4kFflR4kyySv4Hbwb40a5//ipAByQosG ZSFjR8Llnlhd3HlA6dUjTRATfyyS/SIYb5CqhlDl+aXaynw5I3wO4bhyU/1/nZM6Hqm7 t8r52oBZVkUASwiGo+XIQUycK6DG8AGZWwo6OTi/eNdFLyVxhX2eceGalZW8rD1uWquK vH9g== 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=qE1M6AmQFjgNABMwGC/loA+R5NiFaqYwjUR90uESRFY=; b=qk1MT5BXkyWHxZuNV+G/TDOfBT+ZKDAZ107N0penxGfYTm8eCMJ9a/bQP3gLqv2Mq/ m0V3GfiNUQU7zDqlGN035QBA7rNE8dXG8OeecKKjJx3nEsgzqb9U7a+S6MW0w8yC6P3N sFLAzIBnktBfh0qdq4sVL5zUbSakCOkdKW49Y22hlLijtZJsA3LSnUiyd2N/D44Zvu3t iAGamvJPmC7AJUnnZr8y8cArdRnZKERf5XPunY7V5rRKf1T6M9N0FEjZtAPw4l0IXXIn qZMjAOhjZLvtmDfNHYFz6uOzfKmnWe1XTAxjGnwHPP8/JfN9Xn8GYGvP/TnpEsW3VQLr mJTA== X-Gm-Message-State: ALQs6tD7KZCbRhEbmuL462jtSHlY6ciHTBH7D5x0ls9FC0mKLYds4jar tRJn+IBMOYDrnjFMl2V+khAH/L0MPZ7uux2kxE9yng== X-Received: by 10.176.27.133 with SMTP id k5mr15242890uai.2.1522968716565; Thu, 05 Apr 2018 15:51:56 -0700 (PDT) MIME-Version: 1.0 References: <20180404093007.GI4082@hirez.programming.kicks-ass.net> <20180404191724.GF87376@google.com> <20180404205848.GG87376@google.com> <20180404214639.GH87376@google.com> <20180404221744.GI87376@google.com> <20180404233111.GJ87376@google.com> <20180405072017.GN4043@hirez.programming.kicks-ass.net> In-Reply-To: From: James Y Knight Date: Thu, 05 Apr 2018 22:51:30 +0000 Message-ID: Subject: Re: [GIT PULL] x86/build changes for v4.17 To: Linus Torvalds Cc: Peter Zijlstra , mka@chromium.org, Arnd Bergmann , Ingo Molnar , Linux Kernel Mailing List , tglx@linutronix.de, Andrew Morton , Chandler Carruth , Stephen Hines , Nick Desaulniers , Kees Cook , groeck@chromium.org, Greg Hackmann , gregkh@linuxfoundation.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 5, 2018 at 5:13 PM Linus Torvalds wrote: > And btw, I hate how stupid gcc is about "constant size arrays but acts > as a VLA because it wasn't an integer-constant-expression size" > things. > Your code generation example really is a sad sad example of it. A good > optimizer should have generated the same code even if the stupid array > again syntactically was VLA, because it damn well isn't in reality. Unfortunately, that behavior is required by the standard, it's not up to compiler optimization to change. Note that the optimizer in my example _did_ determine that the VLA had a constant size, and generated constant-size stack adjustment code. And it knew the result of the sizeof(), and put the value "4" straight into the return register. The only difference in the codegen from a non-VLA is the difference which was required by the language standard -- the useless call to "function". Note that the return value of the call is unused. And in fact, there is literally no reason for the expression in "sizeof(expression)" to ever be evaluated -- the result of the evaluation can _never_ be used! And, yet, the C99 standard requires that it is evaluated, regardless, when the resulting type of the expression is a VLA type. I have no idea why.... From C99 6.5.3.4 "The sizeof operator", paragraph 2: """ The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is an integer. If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant. """ (C11 says the same thing.)