|
| 1 | +From git@z Thu Jan 1 00:00:00 1970 |
| 2 | +Subject: [PATCH] hexagon: Disable constant extender optimization for LLVM |
| 3 | + prior to 19.1.0 |
| 4 | +From: Nathan Chancellor < [email protected]> |
| 5 | +Date: Mon, 19 Aug 2024 11:16:10 -0700 |
| 6 | +Message-Id: <20240819-hexagon-disable-constant-expander-pass-v1-1-36a734e9527d@kernel.org> |
| 7 | +MIME-Version: 1.0 |
| 8 | +Content-Type: text/plain; charset="utf-8" |
| 9 | +Content-Transfer-Encoding: 7bit |
| 10 | + |
| 11 | +The Hexagon-specific constant extender optimization in LLVM may crash on |
| 12 | +Linux kernel code [1] (such as with a bcachefs change in -next): |
| 13 | + |
| 14 | + clang: llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp:745: bool (anonymous namespace)::HexagonConstExtenders::ExtRoot::operator<(const HCE::ExtRoot &) const: Assertion `ThisB->getParent() == OtherB->getParent()' failed. |
| 15 | + Stack dump: |
| 16 | + 0. Program arguments: clang --target=hexagon-linux-musl ... fs/bcachefs/btree_io.c |
| 17 | + 1. <eof> parser at end of file |
| 18 | + 2. Code generation |
| 19 | + 3. Running pass 'Function Pass Manager' on module 'fs/bcachefs/btree_io.c'. |
| 20 | + 4. Running pass 'Hexagon constant-extender optimization' on function '@__btree_node_lock_nopath' |
| 21 | + |
| 22 | +Without assertions enabled, there is just a hang during compilation. |
| 23 | + |
| 24 | +This has been resolved in LLVM main (20.0.0) [2] and backported to LLVM |
| 25 | +19.1.0 but the kernel supports LLVM 13.0.1 and newer, so disable the |
| 26 | +constant expander optimization using the '-mllvm' option when using a |
| 27 | +toolchain that is not fixed. |
| 28 | + |
| 29 | +Link: https://github.com/llvm/llvm-project/issues/99714 [1] |
| 30 | +Link: https://github.com/llvm/llvm-project/commit/68df06a0b2998765cb0a41353fcf0919bbf57ddb [2] |
| 31 | +Link: https://github.com/llvm/llvm-project/commit/2ab8d93061581edad3501561722ebd5632d73892 [3] |
| 32 | +Reviewed-by: Brian Cain < [email protected]> |
| 33 | +Link: https://lore.kernel.org/r/20240819-hexagon-disable-constant-expander-pass-v1-1-36a734e9527d@kernel.org |
| 34 | +Signed-off-by: Nathan Chancellor < [email protected]> |
| 35 | +--- |
| 36 | + arch/hexagon/Makefile | 6 ++++++ |
| 37 | + 1 file changed, 6 insertions(+) |
| 38 | + |
| 39 | +diff --git a/arch/hexagon/Makefile b/arch/hexagon/Makefile |
| 40 | +index 92d005958dfb..ff172cbe5881 100644 |
| 41 | +--- a/arch/hexagon/Makefile |
| 42 | ++++ b/arch/hexagon/Makefile |
| 43 | +@@ -32,3 +32,9 @@ KBUILD_LDFLAGS += $(ldflags-y) |
| 44 | + TIR_NAME := r19 |
| 45 | + KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__ |
| 46 | + KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME) |
| 47 | ++ |
| 48 | ++# Disable HexagonConstExtenders pass for LLVM versions prior to 19.1.0 |
| 49 | ++# https://github.com/llvm/llvm-project/issues/99714 |
| 50 | ++ifneq ($(call clang-min-version, 190100),y) |
| 51 | ++KBUILD_CFLAGS += -mllvm -hexagon-cext=false |
| 52 | ++endif |
| 53 | + |
| 54 | +--- |
| 55 | +base-commit: 47ac09b91befbb6a235ab620c32af719f8208399 |
| 56 | +change-id: 20240802-hexagon-disable-constant-expander-pass-8b6b61db6afc |
| 57 | + |
| 58 | +Best regards, |
| 59 | +-- |
| 60 | +Nathan Chancellor < [email protected]> |
| 61 | + |
0 commit comments