public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>, "H. Peter Anvin" <hpa@zytor.com>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Andy Lutomirski <luto@kernel.org>,
	Miguel Ojeda <ojeda@kernel.org>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: [PATCH] [RFC] x86: avoid -mtune=atom with clang
Date: Tue, 19 Oct 2021 19:11:08 +0200	[thread overview]
Message-ID: <20211019171121.3510624-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

The clang optimization for atom results in a large number of objtool
warnings like

  drivers/video/hdmi.o: warning: objtool: hdmi_infoframe_check()+0x74: unreachable instruction
  lib/crypto/curve25519.o: warning: objtool: init_module()+0x12: unreachable instruction
  drivers/clk/bcm/clk-iproc-armpll.o: warning: objtool: iproc_armpll_setup()+0x10c: unreachable instruction
  drivers/video/fbdev/core/cfbfillrect.o: warning: objtool: cfb_fillrect()+0xa2: unreachable instruction
  drivers/clk/bcm/clk-iproc-pll.o: warning: objtool: iproc_pll_clk_setup()+0x36d: unreachable instruction
  drivers/clk/bcm/clk-iproc-asiu.o: warning: objtool: iproc_asiu_setup()+0x2cf: unreachable instruction

and in rare cases problems with the register allocator:

  arch/x86/crypto/curve25519-x86_64.c:610:3: error: inline assembly requires more registers than available

  error: ran out of registers during register allocation

All of those can be avoided by changing the -mtune= option for
clang, leaving the -march= option unchanged. It's really a bug
that should be fxied in llvm, but it's fairly clear that the
atom optimizations are not well exercised in llvm, so not
using them is probably the safe choice regardless.

Link: https://github.com/ClangBuiltLinux/linux/issues/1483
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/x86/Makefile        | 4 ++++
 arch/x86/Makefile_32.cpu | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 7488cfbbd2f6..4c6f92b32385 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -120,7 +120,11 @@ else
         cflags-$(CONFIG_MK8)		+= -march=k8
         cflags-$(CONFIG_MPSC)		+= -march=nocona
         cflags-$(CONFIG_MCORE2)		+= -march=core2
+ifdef CONFIG_CC_IS_CLANG
+        cflags-$(CONFIG_MATOM)		+= -march=atom -mtune=generic
+else
         cflags-$(CONFIG_MATOM)		+= -march=atom
+endif
         cflags-$(CONFIG_GENERIC_CPU)	+= -mtune=generic
         KBUILD_CFLAGS += $(cflags-y)
 
diff --git a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu
index 94834c4b5e5e..a17b089f367c 100644
--- a/arch/x86/Makefile_32.cpu
+++ b/arch/x86/Makefile_32.cpu
@@ -33,8 +33,12 @@ cflags-$(CONFIG_MCYRIXIII)	+= $(call cc-option,-march=c3,-march=i486) $(align)
 cflags-$(CONFIG_MVIAC3_2)	+= $(call cc-option,-march=c3-2,-march=i686)
 cflags-$(CONFIG_MVIAC7)		+= -march=i686
 cflags-$(CONFIG_MCORE2)		+= -march=i686 $(call tune,core2)
+ifdef CONFIG_CC_IS_CLANG
+cflags-$(CONFIG_MATOM)		+= -march=atom -mtune=generic
+else
 cflags-$(CONFIG_MATOM)		+= $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
 	$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
+endif
 
 # AMD Elan support
 cflags-$(CONFIG_MELAN)		+= -march=i486
-- 
2.29.2


             reply	other threads:[~2021-10-19 17:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 17:11 Arnd Bergmann [this message]
2021-10-19 19:01 ` [PATCH] [RFC] x86: avoid -mtune=atom with clang Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211019171121.3510624-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=luto@kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=ojeda@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox