Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2140489ybk; Mon, 11 May 2020 12:57:10 -0700 (PDT) X-Google-Smtp-Source: APiQypImo1FDXfb2qAEzU8Wnd98goeq4dLdxPkuqeDqCTQXx8KODE0iTHYjH+Dndf85MYgM4hsVq X-Received: by 2002:aa7:de0b:: with SMTP id h11mr15187745edv.133.1589227030757; Mon, 11 May 2020 12:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589227030; cv=none; d=google.com; s=arc-20160816; b=nOj2njRxPAK2F2HwQcpZL02ItkvtDEuG/IqFVyJbmxPpiYGAe1/oOr6dE42FPivecZ c9zND9ppjdlOQFoIQ6QwNTs0SkvrT228a/n8SpkjCLUOmxIbct4C/vmK9LAt0FQ3fOiL NNW1AtcAX4asGSvY3Gj0l2F84sUy5hqSqkWD2GhJmy799LeDfAVPrbEnbeB9c0OGaddq OwQJmQmBZs1y472sHDAFhO7vcycHqqwpcOYguDrT8jWHz8AwPN062OPwOn6G7jP7LtBp yrMGLVFUmzIH/cOA9UF4BrI5TJeJ+eBIW/y3yO1Ayk2HZe5YfTxHvVKcjZcsG0TehsLI 9BTQ== 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; bh=4J+O5ij9f6iPCsIeld+kaqMUMJVlz/CC6sojBFpIW5A=; b=I/BXC7HZSTvMICb5S4goLM2efp99UDzt+ZnVikFPVTSIT9oPdIBC77IpvSwFoU9uO5 H6LM0EPKMaHIgPiZd2Uuhl17cyrhlJzzPVxLWZBDx4JGs2sMzCNScsR3kxGgSw7oMQeN oNpVd/scEP/EOsAmr9kW5+VgMZ3FsIG34HrCwtnYDOE2i9Eu4x0edX8U3s0/KgFFIOpj VWwQIz0chRy3tK3bQZOkWI8AgcIzuKkx79oMfNpmyuN6SdDBg5AaLueSXO0fr3UwOjO2 On3Ffnoo68JvgZK1zQC9jNOvu3denWa9xJuTgQ5nJzhjLJN+LzP/PidM+qPxQumpPLYp 8haw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="JCn5psV/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id z16si2602790eja.213.2020.05.11.12.56.47; Mon, 11 May 2020 12:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="JCn5psV/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1731132AbgEKTwo (ORCPT + 99 others); Mon, 11 May 2020 15:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728283AbgEKTwo (ORCPT ); Mon, 11 May 2020 15:52:44 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7851C061A0C for ; Mon, 11 May 2020 12:52:43 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id t9so8413930pjw.0 for ; Mon, 11 May 2020 12:52:43 -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=4J+O5ij9f6iPCsIeld+kaqMUMJVlz/CC6sojBFpIW5A=; b=JCn5psV/bUZ7uw45aQpXpO6oHjBJs3tJlx1OkzrSR75S3XPNwlnqhhoGNq5sn8Svb5 gl6KdMmeXeHiITKglSOoPSyFrNImQOvVhPtnpanPwRMRF+/4C/Ux3SZi928JlRWtTvZN /4chmP+QOBe08BzvgBPm4u7MtbqYCRgtzCm3DXn/kCARAeVFpxI7VYryGAYtt1iMTQLB 4yveBDwWX+5J+FAkZ6w+b1nBDRaY3VhRvn9OjqUyKSC21H+FOkFrIT+uZyew73OTguRD lX+bLlKubVSDY/476N6VLLrlG5J6a1O+TC8i+sWoyFH42y2EjfhRUXM/Im60CFp6yFUp rmFA== 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=4J+O5ij9f6iPCsIeld+kaqMUMJVlz/CC6sojBFpIW5A=; b=dXCL61kPGq+jSwC03ZVJrf8YFgyPrRZ7pLVWAWVBOEhffJjBrkOd+wGlYNsL7bqXZa YgU8/5nUzgEdH0OmNZt9Dvmh+oGyyJAi6I6+eJ8HiUi+4EBi0rbXalmBjdBt6+v3azo6 vYEg2qYzjuAxxgJYeO5LEfICoEH7c8JXTg+wBLDaBsvCpXpEsnaJjmoFmCw+Yb32pMpP wEosmvzk3F838GMXJW/kIyt9XtThrAiz1XyIo07HGfblobzIAemWBRvFd0k0gndM6Lmk 5rhhrhBFSC7e5IrZrOoDi7FZtEVbkntWFSd4g6GkSBkFGaL2Cq+SonGmmVMk2eM6y+ss W4yA== X-Gm-Message-State: AGi0PubaGN1D/aHmbbHqb2oEDXrQqfrfImqDZOz6xOGNETF8lsnS4eds /zvcwrwWAgItBRfxMKij/20GFbAJ8uqCX145dsrknA== X-Received: by 2002:a17:90b:957:: with SMTP id dw23mr25045831pjb.101.1589226763110; Mon, 11 May 2020 12:52:43 -0700 (PDT) MIME-Version: 1.0 References: <20200504230309.237398-1-ndesaulniers@google.com> In-Reply-To: From: Nick Desaulniers Date: Mon, 11 May 2020 12:52:31 -0700 Message-ID: Subject: Re: [PATCH] x86: support i386 with Clang To: Linus Torvalds Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , David Woodhouse , Arnd Bergmann , Dmitry Golovin , Dennis Zhou , Tejun Heo , Christoph Lameter , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Al Viro , Josh Poimboeuf , Masami Hiramatsu , Peter Zijlstra , LKML , clang-built-linux 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 Mon, May 11, 2020 at 11:24 AM Linus Torvalds wrote: > > On Mon, May 11, 2020 at 11:12 AM Linus Torvalds > wrote: > > > > Would using "__builtin_choose_expr()" be able to avoid this whole issue? > > We actually have a fair amount of "pick expression based on size", so > with a few helper macros we could make the code look better than the > case statements too. > > Something (ENTIRELY UNTESTED!) like the attached patch, perhaps? > > NOTE! I only converted one single use to that "pick_size_xyz()" model. > If this actually works for clang too, we could do the others. > > I guess I should just test it, since I have that clang tree. Interesting approach. Researching __builtin_choose_expr, it looks like it was cited as prior art for C11's _Generic keyword. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1404.htm I'm kind of tempted now to play with _Generic and see if that makes a difference, though I'm not hopeful. Without checking, I don't know if that will produce warnings with `-std=gnu89`. ... I'm playing around with _Generic now to see if that's a possible solution, but it looks like it can't be used for selecting inline asm constraint strings. But maybe there's another way to use _Generic here. TODO: more testing. I don't quite understand the use of GNU C statement expressions in pick_type_statement, though I'm guessing the return value is important somewhere. Maybe just looking at the preprocessed source would make it clearer. > "why do we cast to unsigned long and then to char, > when we just checked that the size of the type is 1"? Deja vu. I don't remember who I discussed that with, maybe Arnd, but that was something else I had asked at some point. I must have forgotten to look into it more before sending the patch. Can likely drop that at least. -- Thanks, ~Nick Desaulniers