Received: by 10.213.65.68 with SMTP id h4csp2227009imn; Thu, 5 Apr 2018 11:07:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx49iOubcUQJ+LtK2OsnZrOMtoKbD81CfFYyAhUcNxOeh2676xK9SkrHS/Y6rB1ozli4OITc2 X-Received: by 10.99.119.15 with SMTP id s15mr15754071pgc.211.1522951676007; Thu, 05 Apr 2018 11:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522951675; cv=none; d=google.com; s=arc-20160816; b=z9DX3G948Nw3gUHBt28xLDBzODO/bH+/5ve7WPdkXQCSDovaD+8gY6sfjV/w+ibUMC RFtkUxIkknonMqB4s7bqigc7ogDGzE8+YlvaremPE3NHlK7nYy9PsU8bT1m6dZLVhtgF kif+Sqx/z7RvEKw8ZtqQKeJ0gWUWwkAc2mP50qsztv5P87uHkpHgeR4oAyamWVRTodPO aFyFS/7GDsRJ+VZnS8aZUKy3gSi734e0lIViVAH7SVoFXiL0XoSLWzWUzYGAwnhEXgaW 10egxcERdChcr9/sg5nkpSryaEFOcNBKz4B3LQP2uEiJd2WeWL6WSYFa5NH92MhtLdMZ Ydvw== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=lC7Xki6TujqGYWFCKdRXHxFF2/kps0K+0exPm9/0Dvg=; b=A2TYb8WuAlwU91v5H5nIqEz3bSxmrVvyl0pq/6RK1nHey68pJ2krGX50yPYqWOrHNv b98UW9MuxCgFwpKFl6OutCzkWc7QrtqcdGIUcXrvF9I//s+JP4q9/t4iNBFHoquTq2Pn VatDVOzog6bpacfYu3HGHWsIDC+aen+MyGJsFODGUYM+vE7WRsXMRQMANXXyxykz5q+e 9jqhIHnAOnbEZR/K+X/YQKlhat26dYNAOngHr1bB8IAPpJuMYdDHDaj6gn8SenJ9bDJR 1bl6M+Hsh5y1WM5nYIHU9UzOwdGAqxHxhVKhhmENlvB0VpEDP1Sj12LTXOsnH32Jf0nZ yxFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VdhM7L+J; dkim=fail header.i=@linux-foundation.org header.s=google header.b=er7ovSY+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4-v6si6374853plb.641.2018.04.05.11.07.41; Thu, 05 Apr 2018 11:07:55 -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=fail header.i=@gmail.com header.s=20161025 header.b=VdhM7L+J; dkim=fail header.i=@linux-foundation.org header.s=google header.b=er7ovSY+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbeDESGj (ORCPT + 99 others); Thu, 5 Apr 2018 14:06:39 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:39827 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751318AbeDESGh (ORCPT ); Thu, 5 Apr 2018 14:06:37 -0400 Received: by mail-it0-f67.google.com with SMTP id e98-v6so5191422itd.4 for ; Thu, 05 Apr 2018 11:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=lC7Xki6TujqGYWFCKdRXHxFF2/kps0K+0exPm9/0Dvg=; b=VdhM7L+JdCHKSQIiEDGTFGGaX1KxlhUOVybku3wXFWQFxx1Gpia7zQ0yEcvcYPbzfy 7GQqY9LX+7nGb0+6u2UV3xUxCZi/i+fW69EMp9Vg9EuWK1/UczwVCI4MhlJFZ2mNXtF7 /izeJmZLRBYqO2tWxvaFuevvhc24TY+m8XRTnYvXaL4fcwXaa+or0dzOxBiNcYs2XXIw xUJY3Ee7mxmmKj1bbZtMZIFHldmFNPt+OLs0VlBYfINYup7JTJc/brZyoBtolTwHAlR8 B6e56KMGR/OxJGagpMIN6o/iuwhjPWibNBl1l2e7A7VWDqH1d+xHAF34s91JtBOYyWaL MFew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=lC7Xki6TujqGYWFCKdRXHxFF2/kps0K+0exPm9/0Dvg=; b=er7ovSY+dr8JJOe2s6tIeABgcObuZTEN7TiFMOSj25nR+7cKM0kprFDaQ0EMqX8oI8 444HYOD4CMj/173+frDF3iSI2lgKZB7m1CXKlxdZ8hByY9V67h/r6sanWKu9yahQto7l ijVidmMmzcq3dYHhLH78vHeFpaPl/tvN025/A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=lC7Xki6TujqGYWFCKdRXHxFF2/kps0K+0exPm9/0Dvg=; b=LBFzn01LjdGnYbCNJLmHT2zkLiDqolF5aw+HzSd7DHIjaoLWKMTaaSLRs1vDjHztdF 7wNfvYFU4nMK+hVBzKWDVGGSOWH1iIUCil5QfQLv0StXC78qDM8tma1tIP5GbwRGpY/w USshrsTB/V6l0DOpekqnHMusweIVA/346MedL9ebanHthmsRK98cXl7Mql/mN3KVdHFX lAWLQfpW+TOv5jTlj7u41SRBtPHCdCpoBCDp6tqVgU4dfAXTzxtsQbKs82F4zgGSlbr1 3yailRJEdFSdVtotOFv+ZEHtR51ZVWFfsYlwBe4X/iTOd3MKYrUYh8a3oVzFZMsrD4Bf Zmhg== X-Gm-Message-State: ALQs6tDBLNfUTh/CkqjsoFbdvBD+OMKzRoRtoNqY0QIyHAmGtsrh3S0+ KfSzRCyMVRPngXLl7DsZelFhimqB75rkeHX61kg= X-Received: by 2002:a24:7693:: with SMTP id z141-v6mr14452955itb.113.1522951596554; Thu, 05 Apr 2018 11:06:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Thu, 5 Apr 2018 11:06:35 -0700 (PDT) In-Reply-To: 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> From: Linus Torvalds Date: Thu, 5 Apr 2018 11:06:35 -0700 X-Google-Sender-Auth: n3uDBDQQ_ghpoqI4lHdbyGKY01Y Message-ID: Subject: Re: [GIT PULL] x86/build changes for v4.17 To: James Y Knight Cc: Peter Zijlstra , Matthias Kaehlcke , Arnd Bergmann , Ingo Molnar , Linux Kernel Mailing List , Thomas Gleixner , Andrew Morton , Chandler Carruth , Stephen Hines , Nick Desaulniers , Kees Cook , Guenter Roeck , Greg Hackmann , Greg Kroah-Hartman 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 ()() ha On Thu, Apr 5, 2018 at 10:46 AM, James Y Knight wrote: > > GCC, however, mixes up the concept of a C "constant expression" with the > results of running optimization passes such as inlining for its > definition/implementation of __builtin_constant_p. Clang does not, and quite > likely will not ever, do that. Nothing has ever said that "__builtin_constant_p(x)" means "is x an integer constant expression". So there is no mix-up - or rather, *you* are the one mixing things up. The gcc documentation says: "You can use the built-in function __builtin_constant_p to determine if a value is known to be constant at compile time [...]" Note that this has *nothing* to do with the concept of C "integer constant expressions". Yes, integer constant expressions obviously have values that are known to be constant at compile time. But *other* things have values that are known to be constant at compile time too. In fact, we went through a long and painful thing exactly because we wanted to get that "is this an ICE" value, and it turns out that the best way to get that value has nothing to do with any gcc builtin at all, but looks like this: /* Glory to Martin Uecker * #define __is_constexpr(x) \ (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) which is actually impressively subtle, and almost entirely standard C (the only real dependency is "sizeof(void)", and it not being the same as "sizeof(int)"). So honestly, if your "__builtin_constant_p(x)" is just "is 'x' just a C integer constant expression", then your __builtin_constant_p() is not only not compatible with gcc, it isn't really even all that useful. We can do it by hand without using a builtin at all. So if any clang person thinks that it's gcc that is mixing up concepts, you guys need to re-consider. It is simply not true - and *should* not be true - that __builtin_constant_ps anything to do with the "C integer constant expression". It needs to go inside inline functions. That's how we use it, and we often have reasons why it practically has to. Macro argument evaluation rules (and lack of type handling) makes it too painful to use macros everywhere. And even when the __builtin_constant_p itself is in a macro, the macro is then often used by inline functions, so.. Linus