Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp353285lqj; Wed, 10 Apr 2024 12:23:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVY8CRInKkAu3VV8lt4Nw8V9AQ9C8UrAJj/oFQdrkHDaeigJRkg2svNe/mvzC66qKi8sAs4RfqimPmzG9nNS2n9gBlvKUGr9JA12m5YPA== X-Google-Smtp-Source: AGHT+IGwxAC4hpehsPQbmHHO1zXz84mMNHPuaxXAAJ2/Ge/mEA80OI2aHCLLHjDbABvT6oPgSUSZ X-Received: by 2002:a17:902:d2cc:b0:1e0:e6b0:b770 with SMTP id n12-20020a170902d2cc00b001e0e6b0b770mr4787620plc.69.1712777018137; Wed, 10 Apr 2024 12:23:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712777018; cv=pass; d=google.com; s=arc-20160816; b=mvlLlncHZ66162Ch/+Cmi90Cb/y2LRTxuronNllJn+MoGHaPw/sDjFamgHAqMBmSxy xDukh/5wQSU6xwjmu8zsnJ67F5RkvQrwcDSpTn+QSxVNesgPhXF4M/XdhccRS6fxVbSK 9s3VK8F5s9noQxIAE64DNiGqaO0nTTNXYBoaHTdlOtHtb4ArOBWNwMl9dUOLYH6FPuGz 4Di6ruC0VoYWtbPQIkepBMx5I8Y/OLFp+MNoQbRuFrlGMtg6DHPj6q8I4wxGXWAeHF3o IJPuz+ltWH6tVXHzvENo3vb8uU7eldxC+2Hs5WTyajqiMmrJpCfr5kSv8R5cz8ON11So D7KA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=MqRnr/YaOnp8eBWYbEFORhlsTmhT0mCO9vyhiwgW7oI=; fh=Vvv0By7YkyI3/OLy4CddHyzv4YsGa6Mv1WKMoU66z1s=; b=dpE/8DIy5W8LKMKMZe+EpoW3QmylR4nLPMoh/c5IbtKCEotXrjgGijPIy+v2OmEFoV hdm86apF+QWJCU4lIFQRu1txR84OAuFu2S772Ybosf6MWIymvEY3rT8m75oAA0l4xNNf EKMGfPzzmmdVe7aknpeTpqoihdyLFPLMtXHWYtskHzRnU2oszjpK96V8BYEUcq+5mPkE O7bQnaaZ2ZgDJOax9ardYHJnTxEYmGE+LRhsAyM5h9pTinrF61i5jI7XocDIwcaBOP3p H64THkPeeriPVP/qpIdcgmtMy2haTaN3EQ9Nk4ZDBmAxCxp8zCtC6YRSkjkuUWoULqgE xT4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=IPY0K8DI; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-139253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i13-20020a170902c94d00b001e10a526a94si11169690pla.129.2024.04.10.12.23.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 12:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=IPY0K8DI; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-139253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A243E28546B for ; Wed, 10 Apr 2024 19:23:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 65814181322; Wed, 10 Apr 2024 19:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IPY0K8DI" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C577017F370 for ; Wed, 10 Apr 2024 19:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712777001; cv=none; b=o5LNL1wxqGtUybyiTp0Sa7VK7bHBdmyPg3o7Aa8ey5ft0kIxTIYBF1z7LCXLGyEyeEThCUBX7uPXRVBoSo7P5/VAvjmoFpqnd8Vs8SrFx/8KZD+FIk1i4VmQBNH9mFVuZys4DmiJu9lL2QcaviOexKACQhsye5lVSapF36e4ej0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712777001; c=relaxed/simple; bh=lT1Zm8JHcfddh2weMtUQK4dvHTVIqbaTDfgt1QyEJTM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=aBhmR+aUOQEUngEG0oZpO9MEkxO2sBiY+L9zHn1E3lv77D6cp6Ih++blFL0Id4doRZS+YeX57TcYc+YvN7VPBPTsCaIikyMY7llu+nL/cKSWyCT5zwDcRw0JhW4D5TpO+QhJK4bAzJE//r9S9P+1ZECHAVt3ocnNncyC9imbShw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IPY0K8DI; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-56fd95160e5so91a12.0 for ; Wed, 10 Apr 2024 12:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712776998; x=1713381798; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MqRnr/YaOnp8eBWYbEFORhlsTmhT0mCO9vyhiwgW7oI=; b=IPY0K8DIB4JxcC1O1tITCzfEPe7nEDDPSB4R6eVXZTp2p+3EStTKbTr3quYdBNemW7 Q0RB66OTIWxS92Hww8VzFN+Qu4jP/U0VkzK8/Ut+UmfKOhVTlQUXmeBokSRzgRmczcSU ekg8cNL24/jAD3D9HXZ3p3JnQ86vbrWVd7SWzT96PnwpxraaN2UjVvzOvdasYpRUdcUc L2apEcnlP+02032C8GvwUA7xXZQYjlhAthutKgIusASeklyJ7b1mjQHgh2mYa7TO2kxt 394JlFxvoUE/jb0W6dBCFuQrItx8mvc5aAIPh8J0YMJOgIBndJ5UJRSXrvHc/EtlRL4J 0sRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712776998; x=1713381798; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MqRnr/YaOnp8eBWYbEFORhlsTmhT0mCO9vyhiwgW7oI=; b=P5okikkbCb95ufmLthUYQjq4x/qJnc6MCshjJZhLFo4tmbNY9oW8Nsan7gPmmJGB4I 9X1WQoP5gKaP3+k6W2HqdmNJn+U4YcPU94nL0BtfM9bfowB8IdyLUzld1FJ4bXaOlC2H WiY4+8WYV7ykErdRp/pvgaHkOPmCE8MIcom6CLoDiialeE2N8lCrqGnc9+UbqQl6tAGg SP8DrHYbDHMIweWqujQOwKdHFOSjVJaGfVOuWFCgbjqrPD6XXIsrazKvvkfcQcyF+YDd FJPF+1fcxF7Io+Qoc5yfOhcYg4mMXMb/GC2zTPVf6wJsB9jrBPVzIdUhhLHDOqMrB6yf a68A== X-Forwarded-Encrypted: i=1; AJvYcCWu+7Hg9yCzGRbkG49PqNBVpoHMviqm0OoAi9RJwKHdpH6kVrKX0cjqE9cXtehuFPVNGER7wgEaergW7MYJ9uXbqx7J9MKoG3QWBa0U X-Gm-Message-State: AOJu0YwoVkVftdlHAlRHD2XoQ1MQe/5fuCYnCUI/xigE0DlTt/L30BMr /SnqtyR5g4sgUj+WsS+tUqoW9jIY363I5o004YD5+7Kp3v98V6n3XDeiFRojYk3GSfr6vaVRY51 FdSmg0Zh/OqlI+qmNjWWIkGI1APd8r1CVH9k= X-Received: by 2002:a05:6402:214d:b0:56e:72a3:e5a8 with SMTP id bq13-20020a056402214d00b0056e72a3e5a8mr25655edb.3.1712776997947; Wed, 10 Apr 2024 12:23:17 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240408084934.GC21904@noisy.programming.kicks-ass.net> <20240409104540.GB21779@noisy.programming.kicks-ass.net> In-Reply-To: From: Bill Wendling Date: Wed, 10 Apr 2024 12:23:01 -0700 Message-ID: Subject: Re: More annoying code generation by clang To: Nick Desaulniers Cc: Peter Zijlstra , Linus Torvalds , Ingo Molnar , Thomas Gleixner , Peter Anvin , "the arch/x86 maintainers" , Linux Kernel Mailing List , clang-built-linux , Kees Cook Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 9, 2024 at 8:37=E2=80=AFAM Nick Desaulniers wrote: > > On Tue, Apr 9, 2024 at 3:45=E2=80=AFAM Peter Zijlstra wrote: > > > > On Mon, Apr 08, 2024 at 12:42:31PM -0700, Linus Torvalds wrote: > > > > > Actually, one of the github issues pages has more of an explanation > > > (and yes, it's tied to impedance issues between the inline asm syntax > > > and how clang works): > > > > > > https://github.com/llvm/llvm-project/issues/20571#issuecomment-= 980933442 > > > > > > > So that same issue seems to suggest Nick is actually working on this an= d > > got stuff merged. Nick, what is the status of your efforts and should w= e > > indeed do the below as Linus suggests or should he upgrade his compiler= ? > > Sorry, I'm no longer working on the issue. I should mark that as such. > > The feature got hung up on rewriting one of the register allocation > frameworks in llvm. > https://github.com/llvm/llvm-project/pull/74344 > > I have a new set of responsibilities at work so I probably wont be > working on that issue any time soon. > I plan on picking this up. Could you please create a WIP branch on GitHub with your current work? -bw > > > > > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-= clang.h > > > index 49feac0162a5..0dee061fd7a6 100644 > > > --- a/include/linux/compiler-clang.h > > > +++ b/include/linux/compiler-clang.h > > > @@ -118,3 +118,15 @@ > > > > > > #define __diag_ignore_all(option, comment) \ > > > __diag_clang(13, ignore, option) > > > + > > > +/* > > > + * clang has horrible behavior with "g" or "rm" constraints for asm > > > + * inputs, turning them into something worse than "m". Avoid using > > > + * constraints with multiple possible uses (but "ir" seems to be ok)= : > > > + * > > > + * https://github.com/llvm/llvm-project/issues/20571 > > > + * https://github.com/llvm/llvm-project/issues/30873 > > > + * https://github.com/llvm/llvm-project/issues/34837 > > 20571 is the cannonical bug for this. > > > > + */ > > > +#define ASM_INPUT_G "ir" > > > +#define ASM_INPUT_RM "r" > > > diff --git a/include/linux/compiler_types.h b/include/linux/compiler_= types.h > > > index 2abaa3a825a9..e53acd310545 100644 > > > --- a/include/linux/compiler_types.h > > > +++ b/include/linux/compiler_types.h > > > @@ -380,6 +380,15 @@ struct ftrace_likely_data { > > > #define asm_goto_output(x...) asm volatile goto(x) > > > #endif > > > > > > +/* > > > + * Clang has trouble with constraints with multiple > > > + * alternative behaviors (mainly "g" and "rm"). > > > + */ > > > +#ifndef ASM_INPUT_G > > > + #define ASM_INPUT_G "g" > > > + #define ASM_INPUT_RM "rm" > > > +#endif > > > + > > > #ifdef CONFIG_CC_HAS_ASM_INLINE > > > #define asm_inline asm __inline > > > #else > > > -- > > > 2.44.0.330.g4d18c88175 > > > > > > > > -- > Thanks, > ~Nick Desaulniers >