linux-hexagon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hexagon: Disable constant extender optimization for LLVM prior to 19.1.0
@ 2024-08-19 18:16 Nathan Chancellor
  2024-10-01 18:58 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2024-08-19 18:16 UTC (permalink / raw)
  To: Brian Cain, Andrew Morton; +Cc: linux-hexagon, patches, llvm, Nathan Chancellor

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]
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>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hexagon: Disable constant extender optimization for LLVM prior to 19.1.0
  2024-08-19 18:16 [PATCH] hexagon: Disable constant extender optimization for LLVM prior to 19.1.0 Nathan Chancellor
@ 2024-10-01 18:58 ` Nathan Chancellor
  2024-10-01 19:08   ` Brian Cain
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2024-10-01 18:58 UTC (permalink / raw)
  To: Brian Cain, Andrew Morton; +Cc: linux-hexagon, patches, llvm

Ping? This hang is now happening in 6.12-rc1 in our CI.

On Mon, Aug 19, 2024 at 11:16:10AM -0700, Nathan Chancellor wrote:
> 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]
> 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>
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] hexagon: Disable constant extender optimization for LLVM prior to 19.1.0
  2024-10-01 18:58 ` Nathan Chancellor
@ 2024-10-01 19:08   ` Brian Cain
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Cain @ 2024-10-01 19:08 UTC (permalink / raw)
  To: Nathan Chancellor, Andrew Morton
  Cc: linux-hexagon@vger.kernel.org, patches@lists.linux.dev,
	llvm@lists.linux.dev

> -----Original Message-----
> From: Nathan Chancellor <nathan@kernel.org>
> Sent: Tuesday, October 1, 2024 1:59 PM
> To: Brian Cain <bcain@quicinc.com>; Andrew Morton <akpm@linux-
> foundation.org>
> Cc: linux-hexagon@vger.kernel.org; patches@lists.linux.dev;
> llvm@lists.linux.dev
> Subject: Re: [PATCH] hexagon: Disable constant extender optimization for LLVM
> prior to 19.1.0
> 
> WARNING: This email originated from outside of Qualcomm. Please be wary of
> any links or attachments, and do not enable macros.
> 
> Ping? This hang is now happening in 6.12-rc1 in our CI.
> 
> On Mon, Aug 19, 2024 at 11:16:10AM -0700, Nathan Chancellor wrote:
> > 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]
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---

Reviewed-by: Brian Cain <bcain@quicinc.com>

> >  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>
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-01 19:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-19 18:16 [PATCH] hexagon: Disable constant extender optimization for LLVM prior to 19.1.0 Nathan Chancellor
2024-10-01 18:58 ` Nathan Chancellor
2024-10-01 19:08   ` Brian Cain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).