git: a58eb6653223 - stable/13 - libzpool: add workaround for MIPS-specific llvm bug compiling arc.c

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 01 Dec 2024 12:54:37 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=a58eb6653223494cce02faf85d3a49110743b9fc

commit a58eb6653223494cce02faf85d3a49110743b9fc
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-12-01 12:52:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-12-01 12:52:42 +0000

    libzpool: add workaround for MIPS-specific llvm bug compiling arc.c
    
    This works around an assertion in llvm's shrink wrapping analysis pass,
    when compiling arc.c for mips and mips64:
    
      Assertion failed: (PhysReg.isPhysical() && "Unallocated register?!"), function useOrDefCSROrFI, file /usr/src/contrib/llvm-project/llvm/lib/CodeGen/ShrinkWrap.cpp, line 341.
    
    The bug will also be submitted upstream.
    
    Direct commit to stable/13, since MIPS support was removed in 14.0.
---
 cddl/lib/libzpool/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile
index 38490d9cff71..cd9f893c426f 100644
--- a/cddl/lib/libzpool/Makefile
+++ b/cddl/lib/libzpool/Makefile
@@ -265,4 +265,12 @@ CFLAGS.zfs_zstd.c=	-Wno-cast-qual -Wno-pointer-arith
 CFLAGS.zstd.c+=	-fno-tree-vectorize
 CFLAGS.zstd.c+=	${NO_WBITWISE_INSTEAD_OF_LOGICAL}
 
+.include <bsd.compiler.mk>
+
+.if ${MACHINE_CPUARCH} == "mips" && \
+    ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 190000
+# Work around MIPS-specific llvm bug in the Shrink Wrapping analysis pass
+CFLAGS.arc.c+=	-mllvm -enable-shrink-wrap-region-split=false
+.endif
+
 .include <bsd.lib.mk>