Skip to content

Commit

Permalink
patches: mainline: Add patch to avoid timeout with Hexagon
Browse files Browse the repository at this point in the history
See the commit message of the patch itself for further details on why
this is needed.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
  • Loading branch information
nathanchance committed Oct 1, 2024
1 parent 3ef34e1 commit 7817b25
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH] hexagon: Disable constant extender optimization for LLVM
prior to 19.1.0
From: Nathan Chancellor <nathan@kernel.org>
Date: Mon, 19 Aug 2024 11:16:10 -0700
Message-Id: <20240819-hexagon-disable-constant-expander-pass-v1-1-36a734e9527d@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

The Hexagon-specific constant extender optimization in LLVM may crash on
Linux kernel code [1] (such as with a bcachefs change in -next):

clang: llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp:745: bool (anonymous namespace)::HexagonConstExtenders::ExtRoot::operator<(const HCE::ExtRoot &) const: Assertion `ThisB->getParent() == OtherB->getParent()' failed.
Stack dump:
0. Program arguments: clang --target=hexagon-linux-musl ... fs/bcachefs/btree_io.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'fs/bcachefs/btree_io.c'.
4. Running pass 'Hexagon constant-extender optimization' on function '@__btree_node_lock_nopath'

Without assertions enabled, there is just a hang during compilation.

This has been resolved in LLVM main (20.0.0) [2] and backported to LLVM
19.1.0 but the kernel supports LLVM 13.0.1 and newer, so disable the
constant expander optimization using the '-mllvm' option when using a
toolchain that is not fixed.

Link: https://github.com/llvm/llvm-project/issues/99714 [1]
Link: https://github.com/llvm/llvm-project/commit/68df06a0b2998765cb0a41353fcf0919bbf57ddb [2]
Link: https://github.com/llvm/llvm-project/commit/2ab8d93061581edad3501561722ebd5632d73892 [3]
Reviewed-by: Brian Cain <bcain@quicinc.com>
Link: https://lore.kernel.org/r/20240819-hexagon-disable-constant-expander-pass-v1-1-36a734e9527d@kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
arch/hexagon/Makefile | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/hexagon/Makefile b/arch/hexagon/Makefile
index 92d005958dfb..ff172cbe5881 100644
--- a/arch/hexagon/Makefile
+++ b/arch/hexagon/Makefile
@@ -32,3 +32,9 @@ KBUILD_LDFLAGS += $(ldflags-y)
TIR_NAME := r19
KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__
KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME)
+
+# Disable HexagonConstExtenders pass for LLVM versions prior to 19.1.0
+# https://github.com/llvm/llvm-project/issues/99714
+ifneq ($(call clang-min-version, 190100),y)
+KBUILD_CFLAGS += -mllvm -hexagon-cext=false
+endif

---
base-commit: 47ac09b91befbb6a235ab620c32af719f8208399
change-id: 20240802-hexagon-disable-constant-expander-pass-8b6b61db6afc

Best regards,
--
Nathan Chancellor <nathan@kernel.org>

1 change: 1 addition & 0 deletions patches/mainline/series
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
20240819_nathan_hexagon_disable_constant_extender_optimization_for_llvm_prior_to_19_1_0.patch
v2_20240916_dan_carpenter_iio_bmi323_fix_copy_and_paste_bugs_in_suspend_resume.patch

0 comments on commit 7817b25

Please sign in to comment.