Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1333755pxb; Fri, 26 Feb 2021 08:14:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwruZ3mUjuef35SvHF7pYftRSbGTQ2ij1rz/F2SxNOMiaUoGAPAhc4P1it+0qOYJx0lgyF4 X-Received: by 2002:a05:6402:4242:: with SMTP id g2mr4254559edb.103.1614356059933; Fri, 26 Feb 2021 08:14:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614356059; cv=none; d=google.com; s=arc-20160816; b=dN3YvHNUEhUAR/FRgpwYytOZtuDxpOy0LPONqOXOw6QMDEuAP/c0TOkIgyOWVTrTKY ITj2LqW0rj7nYlJPSEMqtrApsAgGo28uDQ8GvSI+/5Zjede/5tbQdmJVUmjEU04p56T7 qheNs937jNMhP2Qf5LCRS2Tyd1NSIpPKXbVYxlN+9ydmSvVK1JU9Gl4dFA32ADeCmhLV 0Z60y291yKQFb4gGtoplbpfTMa2n1fF5KZ9GYJsD9Cr2EKmE2FmVu52m5wlY8eJ0xUFw 4gN1sHSr3AcTUxCdFIcq5wQBRAuRsl2Xa/xx0tkM5qiF966HmuR1VXEWgBFYyEpNmR7I I4iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=t4FnK7H4b3dBGlgxLP0iduaR+uQx3OnuCffK0+i97OE=; b=dsmAeRzy1DtjQykqHLZWESbbe7AIGe/lFHwnNF0Wc06gSloGQmO2NwzZ1JrGJAWFmq 0PRwy+//e/SqURfIeC6D8FbuNchJcOo0MvGYq+spMR99IE3SR+DnBdp3MggO1kLBOe41 q9nxX0591PJz0HMIS4TkAcCfBWzzaLpBklhSyMlcGNRWUtd6bztQXHTiQZU3wWC4Eu68 8YovwpnweFq+pkrx1m/DCVW7zfqjcZxlyphSWSZ9tdjxet5gcWGpei+g4aLKZ9CM5bBy girpEKtFZXTct+rqNtBi1xueaVuEydKB+QoKVcMygpGpSi8NlRUb6PCQ50Up2MsmacN7 JQcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DP9nkO3o; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si2908034ejb.269.2021.02.26.08.13.55; Fri, 26 Feb 2021 08:14:19 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=DP9nkO3o; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbhBZQNG (ORCPT + 99 others); Fri, 26 Feb 2021 11:13:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:42042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbhBZQM7 (ORCPT ); Fri, 26 Feb 2021 11:12:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7822664EBA; Fri, 26 Feb 2021 16:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614355936; bh=C3YYYvLVQ2aWy1CSZtnNQUvgD7cCZHBGlr/W3FNNMxs=; h=From:To:Cc:Subject:Date:From; b=DP9nkO3oybnEAnHFCqYU6CdF/AbL2T+K3usNFtsn/N9/Yn70o/rliMJOb8/WaWYBA d57EoBBjnNAhow4GofagZQCF1EjMWeh2qtYWxT7Q2/aOxtXITbSMYBB3lw4CWilLYg Zexl3Qov2U8PKzyAAXLUD/zU1Bkty2FB87MLC4ViEz8Ff/mRR7+Pe6ZmhkIzEwTcNd SqEsb2UDI2IDem/YpMq+qDnEMYGzGJllqU1MqPodlUlmY/Sqw6vZybTE6YpgStqCWX zj09D3CS2CWUt9S2GaQg4mUKko6HBLUIkmvjstoN4N6dRN1g6k1IEc53f669FkOFBz oIlZmTXT7qF5Q== From: Arnd Bergmann To: Andrew Morton , Masahiro Yamada Cc: Miguel Ojeda , Luc Van Oostenryck , Arnd Bergmann , Nathan Chancellor , Kees Cook , Miguel Ojeda , Nick Desaulniers , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Randy Dunlap , Sami Tolvanen , Marco Elver , Arvind Sankar , clang-built-linux@googlegroups.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-csky@vger.kernel.org Subject: [PATCH] [v2] linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP* Date: Fri, 26 Feb 2021 17:11:12 +0100 Message-Id: <20210226161151.2629097-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann Separating compiler-clang.h from compiler-gcc.h inadventently dropped the definitions of the three HAVE_BUILTIN_BSWAP macros, which requires falling back to the open-coded version and hoping that the compiler detects it. Since all versions of clang support the __builtin_bswap interfaces, add back the flags and have the headers pick these up automatically. This results in a 4% improvement of compilation speed for arm defconfig. Note: it might also be worth revisiting which architectures set CONFIG_ARCH_USE_BUILTIN_BSWAP for one compiler or the other, today this is set on six architectures (arm32, csky, mips, powerpc, s390, x86), while another ten architectures define custom helpers (alpha, arc, ia64, m68k, mips, nios2, parisc, sh, sparc, xtensa), and the rest (arm64, h8300, hexagon, microblaze, nds32, openrisc, riscv) just get the unoptimized version and rely on the compiler to detect it. A long time ago, the compiler builtins were architecture specific, but nowadays, all compilers that are able to build the kernel have correct implementations of them, though some may not be as optimized as the inline asm versions. The patch that dropped the optimization landed in v4.19, so as discussed it would be fairly safe to backport this revert to stable kernels to the 4.19/5.4/5.10 stable kernels, but there is a remaining risk for regressions, and it has no known side-effects besides compile speed. Fixes: 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") Reviewed-by: Nathan Chancellor Reviewed-by: Kees Cook Acked-by: Miguel Ojeda Acked-by: Nick Desaulniers Link: https://lore.kernel.org/lkml/20210225164513.3667778-1-arnd@kernel.org/ Signed-off-by: Arnd Bergmann --- v2: - drop exception for sparse - expand changelog text --- include/linux/compiler-clang.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index 6478bff6fcc2..917f7f88cef0 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -33,6 +33,12 @@ #define __no_sanitize_thread #endif +#if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) +#define __HAVE_BUILTIN_BSWAP32__ +#define __HAVE_BUILTIN_BSWAP64__ +#define __HAVE_BUILTIN_BSWAP16__ +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ + #if __has_feature(undefined_behavior_sanitizer) /* GCC does not have __SANITIZE_UNDEFINED__ */ #define __no_sanitize_undefined \ -- 2.29.2