x86: avoid -mtune=atom with clang
RFC PATCH 1/1 x86: avoid -mtune=atom with clang
From: Arnd Bergmann <[email protected]>
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.
--- arch/x86/Makefile | 4 ++++ arch/x86/Makefile_32.cpu | 4 ++++ 2 files changed, 8 insertions(+)
arch/x86/Makefile +4 -0
@@ -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)
arch/x86/Makefile_32.cpu +4 -0
@@ -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
Signature · 1 line
2.29.2
arch/x86/Makefile else · line 127
Quoted 6 lines · Arnd Bergmann
arch/x86/Makefile +4
-0+ifdef CONFIG_CC_IS_CLANG + cflags-$(CONFIG_MATOM) += -march=atom -mtune=generic +else cflags-$(CONFIG_MATOM) += -march=atom +endif
Is it possible to factor it out? Also, a comment with the LLVM version we last checked would be good. Something like...
cflags-$(CONFIG_MATOM) += -march=atom
# Atom optimizations do not seem well exercised in, at least, LLVM <= 13, # to the point of getting problems with register allocation. ifdef CONFIG_CC_IS_CLANG
cflags-$(CONFIG_MATOM) += -mtune=generic
endif
Cheers,
Miguel