From 91b83aeed686faea9e3461255b4d8e728e6e6be1 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Wed, 4 Feb 2026 11:13:50 -0300 Subject: [PATCH] Update to LLVM 21.1.8 Re-sync files from Rawhide. This also disables the bundled LLVM 20 compat. Resolves: RHEL-100903 Resolves: RHEL-100904 --- ...k-for-cast-when-shufflevector-172443.patch | 137 +++++++++ ...-in-widening-vector-multiplication-1.patch | 191 ++++++++++++ ...essed-debug-level-test-for-s390x-wit.patch | 29 ++ ...4631c1f42dbfce78288b8ae30b5840ed59b3.patch | 276 ++++++++++++++++++ llvm.spec | 164 ++++------- sources | 6 +- 6 files changed, 689 insertions(+), 114 deletions(-) create mode 100644 0001-PowerPC-Add-check-for-cast-when-shufflevector-172443.patch create mode 100644 0001-SystemZ-Fix-code-in-widening-vector-multiplication-1.patch create mode 100644 0001-lld-Adjust-compressed-debug-level-test-for-s390x-wit.patch create mode 100644 43cb4631c1f42dbfce78288b8ae30b5840ed59b3.patch diff --git a/0001-PowerPC-Add-check-for-cast-when-shufflevector-172443.patch b/0001-PowerPC-Add-check-for-cast-when-shufflevector-172443.patch new file mode 100644 index 0000000..1f6c0ad --- /dev/null +++ b/0001-PowerPC-Add-check-for-cast-when-shufflevector-172443.patch @@ -0,0 +1,137 @@ +From 98b82f90dfb7865ae4dbfcb5a83a9e817e7894a1 Mon Sep 17 00:00:00 2001 +From: Kevin Per +Date: Thu, 18 Dec 2025 10:14:01 +0100 +Subject: [PATCH] [PowerPC]: Add check for cast when shufflevector (#172443) + +The crash happens because the cast for `Mask = +cast(Res)->getMask();` fails for node `t197: v16i8 += vector_shuffle<16,17,18,19,4,5,6,7,8,9,10,11,u,u,u,u> t196, t196`. +However, both `LHS` and `RHS` are the same node, so +`DAG.getCommutedVectorShuffle` doesn't return a `ShuffleVectorSDNode` +and crashes. The fix is to add a check before the cast is performed. + +Closes https://github.com/llvm/llvm-project/issues/172265 +--- + llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 4 + + .../test/CodeGen/PowerPC/vec_shuffle_le_be.ll | 94 +++++++++++++++++++ + 2 files changed, 98 insertions(+) + create mode 100644 llvm/test/CodeGen/PowerPC/vec_shuffle_le_be.ll + +diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +index 5b1d9f814806..21297b812968 100644 +--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp ++++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +@@ -16886,6 +16886,10 @@ SDValue PPCTargetLowering::combineVectorShuffle(ShuffleVectorSDNode *SVN, + RHS.getOpcode() != ISD::VECTOR_SHUFFLE) { + std::swap(LHS, RHS); + Res = DAG.getCommutedVectorShuffle(*SVN); ++ ++ if (!isa(Res)) ++ return Res; ++ + Mask = cast(Res)->getMask(); + } + +diff --git a/llvm/test/CodeGen/PowerPC/vec_shuffle_le_be.ll b/llvm/test/CodeGen/PowerPC/vec_shuffle_le_be.ll +new file mode 100644 +index 000000000000..24c1e54dd952 +--- /dev/null ++++ b/llvm/test/CodeGen/PowerPC/vec_shuffle_le_be.ll +@@ -0,0 +1,94 @@ ++; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ++; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-unknown-linux-gnu | FileCheck -check-prefix=CHECK-LE %s ++; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck -check-prefix=CHECK-BE %s ++ ++define <32 x i32> @issue_172265(<32 x i32> %BS_ARG_1, <3 x i32> %0) { ++; CHECK-LABEL: issue_172265: ++; CHECK: # %bb.0: # %entry ++; CHECK-NEXT: addis 3, 2, .LCPI18_0@toc@ha ++; CHECK-NEXT: vspltw 3, 10, 1 ++; CHECK-NEXT: addi 3, 3, .LCPI18_0@toc@l ++; CHECK-NEXT: vmr 7, 3 ++; CHECK-NEXT: lvx 4, 0, 3 ++; CHECK-NEXT: addis 3, 2, .LCPI18_1@toc@ha ++; CHECK-NEXT: addi 3, 3, .LCPI18_1@toc@l ++; CHECK-NEXT: vmr 8, 3 ++; CHECK-NEXT: vmr 9, 3 ++; CHECK-NEXT: vperm 4, 3, 3, 4 ++; CHECK-NEXT: lvx 1, 0, 3 ++; CHECK-NEXT: addis 3, 2, .LCPI18_2@toc@ha ++; CHECK-NEXT: addi 3, 3, .LCPI18_2@toc@l ++; CHECK-NEXT: lvx 5, 0, 3 ++; CHECK-NEXT: addis 3, 2, .LCPI18_3@toc@ha ++; CHECK-NEXT: addi 3, 3, .LCPI18_3@toc@l ++; CHECK-NEXT: lvx 6, 0, 3 ++; CHECK-NEXT: addis 3, 2, .LCPI18_4@toc@ha ++; CHECK-NEXT: addi 3, 3, .LCPI18_4@toc@l ++; CHECK-NEXT: vperm 4, 2, 4, 1 ++; CHECK-NEXT: lvx 2, 0, 3 ++; CHECK-NEXT: vperm 0, 3, 3, 5 ++; CHECK-NEXT: vperm 5, 3, 3, 6 ++; CHECK-NEXT: vperm 6, 3, 3, 2 ++; CHECK-NEXT: vmr 2, 0 ++; CHECK-NEXT: blr ++; CHECK-LE-LABEL: issue_172265: ++; CHECK-LE: # %bb.0: # %entry ++; CHECK-LE-NEXT: addis 3, 2, .LCPI0_0@toc@ha ++; CHECK-LE-NEXT: xxspltw 35, 42, 1 ++; CHECK-LE-NEXT: addi 3, 3, .LCPI0_0@toc@l ++; CHECK-LE-NEXT: vmr 7, 3 ++; CHECK-LE-NEXT: vmr 8, 3 ++; CHECK-LE-NEXT: vmr 9, 3 ++; CHECK-LE-NEXT: lxvd2x 0, 0, 3 ++; CHECK-LE-NEXT: addis 3, 2, .LCPI0_1@toc@ha ++; CHECK-LE-NEXT: addi 3, 3, .LCPI0_1@toc@l ++; CHECK-LE-NEXT: lxvd2x 1, 0, 3 ++; CHECK-LE-NEXT: addis 3, 2, .LCPI0_2@toc@ha ++; CHECK-LE-NEXT: addi 3, 3, .LCPI0_2@toc@l ++; CHECK-LE-NEXT: lxvd2x 2, 0, 3 ++; CHECK-LE-NEXT: addis 3, 2, .LCPI0_3@toc@ha ++; CHECK-LE-NEXT: addi 3, 3, .LCPI0_3@toc@l ++; CHECK-LE-NEXT: xxswapd 36, 0 ++; CHECK-LE-NEXT: lxvd2x 0, 0, 3 ++; CHECK-LE-NEXT: vperm 4, 2, 3, 4 ++; CHECK-LE-NEXT: xxswapd 37, 1 ++; CHECK-LE-NEXT: vperm 2, 3, 3, 5 ++; CHECK-LE-NEXT: xxswapd 32, 2 ++; CHECK-LE-NEXT: vperm 5, 3, 3, 0 ++; CHECK-LE-NEXT: xxswapd 33, 0 ++; CHECK-LE-NEXT: vperm 6, 3, 3, 1 ++; CHECK-LE-NEXT: blr ++; ++; CHECK-BE-LABEL: issue_172265: ++; CHECK-BE: # %bb.0: # %entry ++; CHECK-BE-NEXT: addis 3, 2, .LCPI0_0@toc@ha ++; CHECK-BE-NEXT: vspltw 3, 10, 2 ++; CHECK-BE-NEXT: addi 3, 3, .LCPI0_0@toc@l ++; CHECK-BE-NEXT: vmr 7, 3 ++; CHECK-BE-NEXT: lvx 4, 0, 3 ++; CHECK-BE-NEXT: addis 3, 2, .LCPI0_2@toc@ha ++; CHECK-BE-NEXT: addi 3, 3, .LCPI0_2@toc@l ++; CHECK-BE-NEXT: lvx 5, 0, 3 ++; CHECK-BE-NEXT: addis 3, 2, .LCPI0_3@toc@ha ++; CHECK-BE-NEXT: addi 3, 3, .LCPI0_3@toc@l ++; CHECK-BE-NEXT: vperm 0, 3, 3, 5 ++; CHECK-BE-NEXT: lvx 5, 0, 3 ++; CHECK-BE-NEXT: addis 3, 2, .LCPI0_1@toc@ha ++; CHECK-BE-NEXT: addi 3, 3, .LCPI0_1@toc@l ++; CHECK-BE-NEXT: lvx 1, 0, 3 ++; CHECK-BE-NEXT: addis 3, 2, .LCPI0_4@toc@ha ++; CHECK-BE-NEXT: addi 3, 3, .LCPI0_4@toc@l ++; CHECK-BE-NEXT: vperm 4, 3, 3, 4 ++; CHECK-BE-NEXT: vperm 4, 4, 2, 1 ++; CHECK-BE-NEXT: lvx 2, 0, 3 ++; CHECK-BE-NEXT: vperm 5, 3, 3, 5 ++; CHECK-BE-NEXT: vperm 6, 3, 3, 2 ++; CHECK-BE-NEXT: vmr 2, 0 ++; CHECK-BE-NEXT: vmr 8, 3 ++; CHECK-BE-NEXT: vmr 9, 3 ++; CHECK-BE-NEXT: blr ++entry: ++ %vecinit37 = shufflevector <3 x i32> %0, <3 x i32> zeroinitializer, <32 x i32> ++ %shuffle56 = shufflevector <32 x i32> %vecinit37, <32 x i32> %BS_ARG_1, <32 x i32> ++ ret <32 x i32> %shuffle56 ++} +-- +2.52.0 + diff --git a/0001-SystemZ-Fix-code-in-widening-vector-multiplication-1.patch b/0001-SystemZ-Fix-code-in-widening-vector-multiplication-1.patch new file mode 100644 index 0000000..4de2dc9 --- /dev/null +++ b/0001-SystemZ-Fix-code-in-widening-vector-multiplication-1.patch @@ -0,0 +1,191 @@ +From fc12fc635b96e9fa521a33eb31336c539eed1918 Mon Sep 17 00:00:00 2001 +From: sujianIBM <98488060+sujianIBM@users.noreply.github.com> +Date: Thu, 31 Jul 2025 13:18:23 -0400 +Subject: [PATCH] [SystemZ] Fix code in widening vector multiplication + (#150836) + +Commit cdc7864 has an error which would wrongly fold widening +multiplications into an even/odd widening operation. +This PR fixes it and adds tests to check scenarios which should not be +folded into an even/odd widening operation are actually not. +--- + .../Target/SystemZ/SystemZISelLowering.cpp | 2 +- + llvm/test/CodeGen/SystemZ/vec-mul-07.ll | 114 ++++++++++++++++++ + 2 files changed, 115 insertions(+), 1 deletion(-) + +diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +index e30d7235b81b..fb0a47dc9dc4 100644 +--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp ++++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +@@ -9044,7 +9044,7 @@ static unsigned detectEvenOddMultiplyOperand(const SelectionDAG &DAG, + if (unsigned(ShuffleMask[Elt]) != 2 * Elt) + CanUseEven = false; + if (unsigned(ShuffleMask[Elt]) != 2 * Elt + 1) +- CanUseEven = true; ++ CanUseOdd = false; + } + Op = Op.getOperand(0); + if (CanUseEven) +diff --git a/llvm/test/CodeGen/SystemZ/vec-mul-07.ll b/llvm/test/CodeGen/SystemZ/vec-mul-07.ll +index 73c7a8dec5df..583561625cfc 100644 +--- a/llvm/test/CodeGen/SystemZ/vec-mul-07.ll ++++ b/llvm/test/CodeGen/SystemZ/vec-mul-07.ll +@@ -3,6 +3,23 @@ + ; + ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s + ++; Test a v16i8 -> v8i16 unsigned widening multiplication ++; which is not folded into an even/odd widening operation. ++define <8 x i16> @f1_not(<16 x i8> %val1, <16 x i8> %val2) { ++; CHECK-LABEL: f1_not: ++; CHECK: # %bb.0: ++; CHECK-NEXT: vuplhb %v0, %v24 ++; CHECK-NEXT: vuplhb %v1, %v26 ++; CHECK-NEXT: vmlhw %v24, %v0, %v1 ++; CHECK-NEXT: br %r14 ++ %shuf1 = shufflevector <16 x i8> %val1, <16 x i8> poison, <8 x i32> ++ %zext1 = zext <8 x i8> %shuf1 to <8 x i16> ++ %shuf2 = shufflevector <16 x i8> %val2, <16 x i8> poison, <8 x i32> ++ %zext2 = zext <8 x i8> %shuf2 to <8 x i16> ++ %ret = mul <8 x i16> %zext1, %zext2 ++ ret <8 x i16> %ret ++} ++ + ; Test a v16i8 (even) -> v8i16 unsigned widening multiplication. + define <8 x i16> @f1(<16 x i8> %val1, <16 x i8> %val2) { + ; CHECK-LABEL: f1: +@@ -31,6 +48,23 @@ define <8 x i16> @f2(<16 x i8> %val1, <16 x i8> %val2) { + ret <8 x i16> %ret + } + ++; Test a v16i8 -> v8i16 signed widening multiplication ++; which is not folded into an even/odd widening operation. ++define <8 x i16> @f3_not(<16 x i8> %val1, <16 x i8> %val2) { ++; CHECK-LABEL: f3_not: ++; CHECK: # %bb.0: ++; CHECK-NEXT: vuphb %v0, %v26 ++; CHECK-NEXT: vuphb %v1, %v24 ++; CHECK-NEXT: vmlhw %v24, %v1, %v0 ++; CHECK-NEXT: br %r14 ++ %shuf1 = shufflevector <16 x i8> %val1, <16 x i8> poison, <8 x i32> ++ %sext1 = sext <8 x i8> %shuf1 to <8 x i16> ++ %shuf2 = shufflevector <16 x i8> %val2, <16 x i8> poison, <8 x i32> ++ %sext2 = sext <8 x i8> %shuf2 to <8 x i16> ++ %ret = mul <8 x i16> %sext1, %sext2 ++ ret <8 x i16> %ret ++} ++ + ; Test a v16i8 (even) -> v8i16 signed widening multiplication. + define <8 x i16> @f3(<16 x i8> %val1, <16 x i8> %val2) { + ; CHECK-LABEL: f3: +@@ -59,6 +93,23 @@ define <8 x i16> @f4(<16 x i8> %val1, <16 x i8> %val2) { + ret <8 x i16> %ret + } + ++; Test a v8i16 -> v4i32 unsigned widening multiplication ++; which is not folded into an even/odd widening operation. ++define <4 x i32> @f5_not(<8 x i16> %val1, <8 x i16> %val2) { ++; CHECK-LABEL: f5_not: ++; CHECK: # %bb.0: ++; CHECK-NEXT: vuplhh %v0, %v24 ++; CHECK-NEXT: vuplhh %v1, %v26 ++; CHECK-NEXT: vmlf %v24, %v0, %v1 ++; CHECK-NEXT: br %r14 ++ %shuf1 = shufflevector <8 x i16> %val1, <8 x i16> poison, <4 x i32> ++ %zext1 = zext <4 x i16> %shuf1 to <4 x i32> ++ %shuf2 = shufflevector <8 x i16> %val2, <8 x i16> poison, <4 x i32> ++ %zext2 = zext <4 x i16> %shuf2 to <4 x i32> ++ %ret = mul <4 x i32> %zext1, %zext2 ++ ret <4 x i32> %ret ++} ++ + ; Test a v8i16 (even) -> v4i32 unsigned widening multiplication. + define <4 x i32> @f5(<8 x i16> %val1, <8 x i16> %val2) { + ; CHECK-LABEL: f5: +@@ -87,6 +138,23 @@ define <4 x i32> @f6(<8 x i16> %val1, <8 x i16> %val2) { + ret <4 x i32> %ret + } + ++; Test a v8i16 -> v4i32 signed widening multiplication ++; which is not folded into an even/odd widening operation. ++define <4 x i32> @f7_not(<8 x i16> %val1, <8 x i16> %val2) { ++; CHECK-LABEL: f7_not: ++; CHECK: # %bb.0: ++; CHECK-NEXT: vuphh %v0, %v26 ++; CHECK-NEXT: vuphh %v1, %v24 ++; CHECK-NEXT: vmlf %v24, %v1, %v0 ++; CHECK-NEXT: br %r14 ++ %shuf1 = shufflevector <8 x i16> %val1, <8 x i16> poison, <4 x i32> ++ %sext1 = sext <4 x i16> %shuf1 to <4 x i32> ++ %shuf2 = shufflevector <8 x i16> %val2, <8 x i16> poison, <4 x i32> ++ %sext2 = sext <4 x i16> %shuf2 to <4 x i32> ++ %ret = mul <4 x i32> %sext1, %sext2 ++ ret <4 x i32> %ret ++} ++ + ; Test a v8i16 (even) -> v4i32 signed widening multiplication. + define <4 x i32> @f7(<8 x i16> %val1, <8 x i16> %val2) { + ; CHECK-LABEL: f7: +@@ -115,6 +183,29 @@ define <4 x i32> @f8(<8 x i16> %val1, <8 x i16> %val2) { + ret <4 x i32> %ret + } + ++; Test a v4i32 -> v2i64 unsigned widening multiplication ++; which is not folded into an even/odd widening operation. ++define <2 x i64> @f9_not(<4 x i32> %val1, <4 x i32> %val2) { ++; CHECK-LABEL: f9_not: ++; CHECK: # %bb.0: ++; CHECK-NEXT: vuplhf %v0, %v24 ++; CHECK-NEXT: vuplhf %v1, %v26 ++; CHECK-NEXT: vlgvg %r0, %v1, 1 ++; CHECK-NEXT: vlgvg %r1, %v0, 1 ++; CHECK-NEXT: msgr %r1, %r0 ++; CHECK-NEXT: vlgvg %r0, %v1, 0 ++; CHECK-NEXT: vlgvg %r2, %v0, 0 ++; CHECK-NEXT: msgr %r2, %r0 ++; CHECK-NEXT: vlvgp %v24, %r2, %r1 ++; CHECK-NEXT: br %r14 ++ %shuf1 = shufflevector <4 x i32> %val1, <4 x i32> poison, <2 x i32> ++ %zext1 = zext <2 x i32> %shuf1 to <2 x i64> ++ %shuf2 = shufflevector <4 x i32> %val2, <4 x i32> poison, <2 x i32> ++ %zext2 = zext <2 x i32> %shuf2 to <2 x i64> ++ %ret = mul <2 x i64> %zext1, %zext2 ++ ret <2 x i64> %ret ++} ++ + ; Test a v4i32 (even) -> v2i64 unsigned widening multiplication. + define <2 x i64> @f9(<4 x i32> %val1, <4 x i32> %val2) { + ; CHECK-LABEL: f9: +@@ -143,6 +234,29 @@ define <2 x i64> @f10(<4 x i32> %val1, <4 x i32> %val2) { + ret <2 x i64> %ret + } + ++; Test a v4i32 -> v2i64 signed widening multiplication ++; which is not folded into an even/odd widening operation. ++define <2 x i64> @f11_not(<4 x i32> %val1, <4 x i32> %val2) { ++; CHECK-LABEL: f11_not: ++; CHECK: # %bb.0: ++; CHECK-NEXT: vuphf %v0, %v24 ++; CHECK-NEXT: vuphf %v1, %v26 ++; CHECK-NEXT: vlgvg %r0, %v1, 1 ++; CHECK-NEXT: vlgvg %r1, %v0, 1 ++; CHECK-NEXT: msgr %r1, %r0 ++; CHECK-NEXT: vlgvg %r0, %v1, 0 ++; CHECK-NEXT: vlgvg %r2, %v0, 0 ++; CHECK-NEXT: msgr %r2, %r0 ++; CHECK-NEXT: vlvgp %v24, %r2, %r1 ++; CHECK-NEXT: br %r14 ++ %shuf1 = shufflevector <4 x i32> %val1, <4 x i32> poison, <2 x i32> ++ %sext1 = sext <2 x i32> %shuf1 to <2 x i64> ++ %shuf2 = shufflevector <4 x i32> %val2, <4 x i32> poison, <2 x i32> ++ %sext2 = sext <2 x i32> %shuf2 to <2 x i64> ++ %ret = mul <2 x i64> %sext1, %sext2 ++ ret <2 x i64> %ret ++} ++ + ; Test a v4i32 (even) -> v2i64 signed widening multiplication. + define <2 x i64> @f11(<4 x i32> %val1, <4 x i32> %val2) { + ; CHECK-LABEL: f11: +-- +2.52.0 + diff --git a/0001-lld-Adjust-compressed-debug-level-test-for-s390x-wit.patch b/0001-lld-Adjust-compressed-debug-level-test-for-s390x-wit.patch new file mode 100644 index 0000000..20dd146 --- /dev/null +++ b/0001-lld-Adjust-compressed-debug-level-test-for-s390x-wit.patch @@ -0,0 +1,29 @@ +From 4fbbdb4f6b95158b87e1b072b3a246722ccf3b7d Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Fri, 19 Dec 2025 17:02:24 +0100 +Subject: [PATCH] [lld] Adjust compressed-debug-level test for s390x with + DFLTCC (#172972) + +After enabling DFLTCC in zlib-ng for s390x this test starts failing, +because slightly better compression is produced at level 1. Add 1c as a +permissible output. +--- + lld/test/ELF/compressed-debug-level.test | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lld/test/ELF/compressed-debug-level.test b/lld/test/ELF/compressed-debug-level.test +index 5a4d37e31eca..7d64298e518f 100644 +--- a/lld/test/ELF/compressed-debug-level.test ++++ b/lld/test/ELF/compressed-debug-level.test +@@ -18,7 +18,7 @@ + # RUN: llvm-readelf --sections %t.6 | FileCheck -check-prefixes=HEADER,LEVEL6 %s + + # HEADER: [Nr] Name Type Address Off Size +-# LEVEL1: [ 1] .debug_info PROGBITS 00000000 000094 0000{{1[def]|21}} ++# LEVEL1: [ 1] .debug_info PROGBITS 00000000 000094 0000{{1[cdef]|21}} + # LEVEL6: [ 1] .debug_info PROGBITS 00000000 000094 00001{{[abc]}} + + ## A little arbitrary debug section which has a different size after +-- +2.50.1 + diff --git a/43cb4631c1f42dbfce78288b8ae30b5840ed59b3.patch b/43cb4631c1f42dbfce78288b8ae30b5840ed59b3.patch new file mode 100644 index 0000000..47b333b --- /dev/null +++ b/43cb4631c1f42dbfce78288b8ae30b5840ed59b3.patch @@ -0,0 +1,276 @@ +From 43cb4631c1f42dbfce78288b8ae30b5840ed59b3 Mon Sep 17 00:00:00 2001 +From: Ebuka Ezike +Date: Thu, 8 Jan 2026 18:46:03 +0000 +Subject: [PATCH] [lldb] Fix typed commands not shown on the screen (#174216) + +The cause is that in `python3.14`, `fcntl.ioctl` now throws a buffer +overflow error +when the buffer is too small or too large (see +https://github.com/python/cpython/pull/132919). This caused the Python +interpreter to fail terminal detection and not properly echo user +commands back to the screen. + +Fix by dropping the custom terminal size check entirely and using the +built-in `sys.stdin.isatty()` instead. + +Fixes #173302 +--- + .../Python/lldbsuite/test/lldbpexpect.py | 1 + + .../Interpreter/embedded_interpreter.py | 59 +++--------------- + .../python_api/file_handle/TestFileHandle.py | 48 +++++++++++++- + .../API/terminal/TestPythonInterpreterEcho.py | 62 +++++++++++++++++++ + .../Shell/ScriptInterpreter/Python/io.test | 12 ++++ + 5 files changed, 131 insertions(+), 51 deletions(-) + create mode 100644 lldb/test/API/terminal/TestPythonInterpreterEcho.py + create mode 100644 lldb/test/Shell/ScriptInterpreter/Python/io.test + +diff --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py +index 3279e1fd39f8c..03b2500fbda52 100644 +--- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py ++++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py +@@ -10,6 +10,7 @@ + + + @skipIfRemote ++@skipIfWindows + @add_test_categories(["pexpect"]) + class PExpectTest(TestBase): + NO_DEBUG_INFO_TESTCASE = True +diff --git a/lldb/source/Interpreter/embedded_interpreter.py b/lldb/source/Interpreter/embedded_interpreter.py +index 42a9ab5fc367a..12c47bd712816 100644 +--- a/lldb/source/Interpreter/embedded_interpreter.py ++++ b/lldb/source/Interpreter/embedded_interpreter.py +@@ -32,18 +32,6 @@ def is_libedit(): + g_run_one_line_str = None + + +-def get_terminal_size(fd): +- try: +- import fcntl +- import termios +- import struct +- +- hw = struct.unpack("hh", fcntl.ioctl(fd, termios.TIOCGWINSZ, "1234")) +- except: +- hw = (0, 0) +- return hw +- +- + class LLDBExit(SystemExit): + pass + +@@ -74,50 +62,21 @@ def readfunc_stdio(prompt): + def run_python_interpreter(local_dict): + # Pass in the dictionary, for continuity from one session to the next. + try: +- fd = sys.stdin.fileno() +- interacted = False +- if get_terminal_size(fd)[1] == 0: +- try: +- import termios +- +- old = termios.tcgetattr(fd) +- if old[3] & termios.ECHO: +- # Need to turn off echoing and restore +- new = termios.tcgetattr(fd) +- new[3] = new[3] & ~termios.ECHO +- try: +- termios.tcsetattr(fd, termios.TCSADRAIN, new) +- interacted = True +- code.interact( +- banner="Python Interactive Interpreter. To exit, type 'quit()', 'exit()'.", +- readfunc=readfunc_stdio, +- local=local_dict, +- ) +- finally: +- termios.tcsetattr(fd, termios.TCSADRAIN, old) +- except: +- pass +- # Don't need to turn off echoing +- if not interacted: +- code.interact( +- banner="Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.", +- readfunc=readfunc_stdio, +- local=local_dict, +- ) +- else: +- # We have a real interactive terminal +- code.interact( +- banner="Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.", +- readfunc=readfunc, +- local=local_dict, +- ) ++ banner = "Python Interactive Interpreter. To exit, type 'quit()', 'exit()'." ++ input_func = readfunc_stdio ++ ++ is_atty = sys.stdin.isatty() ++ if is_atty: ++ banner = "Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D." ++ input_func = readfunc ++ ++ code.interact(banner=banner, readfunc=input_func, local=local_dict) + except LLDBExit: + pass + except SystemExit as e: + if e.code: + print("Script exited with code %s" % e.code) + +- + def run_one_line(local_dict, input_string): + global g_run_one_line_str + try: +diff --git a/lldb/test/API/python_api/file_handle/TestFileHandle.py b/lldb/test/API/python_api/file_handle/TestFileHandle.py +index b38585577f6f6..707044a3afb0f 100644 +--- a/lldb/test/API/python_api/file_handle/TestFileHandle.py ++++ b/lldb/test/API/python_api/file_handle/TestFileHandle.py +@@ -111,10 +111,11 @@ def setUp(self): + super(FileHandleTestCase, self).setUp() + self.out_filename = self.getBuildArtifact("output") + self.in_filename = self.getBuildArtifact("input") ++ self.err_filename = self.getBuildArtifact("error") + + def tearDown(self): + super(FileHandleTestCase, self).tearDown() +- for name in (self.out_filename, self.in_filename): ++ for name in (self.out_filename, self.in_filename, self.err_filename): + if os.path.exists(name): + os.unlink(name) + +@@ -679,6 +680,51 @@ def test_stdout_file(self): + lines = [x for x in f.read().strip().split() if x != "7"] + self.assertEqual(lines, ["foobar"]) + ++ def test_stdout_file_interactive(self): ++ """Ensure when we read stdin from a file, outputs from python goes to the right I/O stream.""" ++ with open(self.in_filename, "w") as f: ++ f.write( ++ "script --language python --\nvalue = 250 + 5\nprint(value)\nprint(vel)" ++ ) ++ ++ with open(self.out_filename, "w") as outf, open( ++ self.in_filename, "r" ++ ) as inf, open(self.err_filename, "w") as errf: ++ status = self.dbg.SetOutputFile(lldb.SBFile(outf)) ++ self.assertSuccess(status) ++ status = self.dbg.SetErrorFile(lldb.SBFile(errf)) ++ self.assertSuccess(status) ++ status = self.dbg.SetInputFile(lldb.SBFile(inf)) ++ self.assertSuccess(status) ++ auto_handle_events = True ++ spawn_thread = False ++ num_errs = 0 ++ quit_requested = False ++ stopped_for_crash = False ++ opts = lldb.SBCommandInterpreterRunOptions() ++ self.dbg.RunCommandInterpreter( ++ auto_handle_events, ++ spawn_thread, ++ opts, ++ num_errs, ++ quit_requested, ++ stopped_for_crash, ++ ) ++ self.dbg.GetOutputFile().Flush() ++ expected_out_text = "255" ++ expected_err_text = "NameError" ++ # check stdout ++ with open(self.out_filename, "r") as f: ++ out_text = f.read() ++ self.assertIn(expected_out_text, out_text) ++ self.assertNotIn(expected_err_text, out_text) ++ ++ # check stderr ++ with open(self.err_filename, "r") as f: ++ err_text = f.read() ++ self.assertIn(expected_err_text, err_text) ++ self.assertNotIn(expected_out_text, err_text) ++ + def test_identity(self): + f = io.StringIO() + sbf = lldb.SBFile(f) +diff --git a/lldb/test/API/terminal/TestPythonInterpreterEcho.py b/lldb/test/API/terminal/TestPythonInterpreterEcho.py +new file mode 100644 +index 0000000000000..758a4f9cede5a +--- /dev/null ++++ b/lldb/test/API/terminal/TestPythonInterpreterEcho.py +@@ -0,0 +1,62 @@ ++""" ++Test that typing python expression in the terminal is echoed back to stdout. ++""" ++ ++from lldbsuite.test.decorators import skipIfAsan ++from lldbsuite.test.lldbpexpect import PExpectTest ++ ++ ++@skipIfAsan ++class PythonInterpreterEchoTest(PExpectTest): ++ PYTHON_PROMPT = ">>> " ++ ++ def verify_command_echo( ++ self, command: str, expected_output: str = "", is_regex: bool = False ++ ): ++ assert self.child != None ++ child = self.child ++ self.assertIsNotNone(self.child, "expected a running lldb process.") ++ ++ child.sendline(command) ++ ++ # Build pattern list: match whichever comes first (output or prompt). ++ # This prevents waiting for a timeout if there's no match. ++ pattern = [] ++ match_expected = expected_output and len(expected_output) > 0 ++ ++ if match_expected: ++ pattern.append(expected_output) ++ pattern.append(self.PYTHON_PROMPT) ++ ++ expect_func = child.expect if is_regex else child.expect_exact ++ match_idx = expect_func(pattern) ++ if match_expected: ++ self.assertEqual( ++ match_idx, 0, "Expected output `{expected_output}` in stdout." ++ ) ++ ++ self.assertIsNotNone(self.child.before, "Expected output before prompt") ++ self.assertIsInstance(self.child.before, bytes) ++ echoed_text: str = self.child.before.decode("ascii").strip() ++ self.assertEqual( ++ command, echoed_text, f"Command '{command}' should be echoed to stdout." ++ ) ++ ++ if match_expected: ++ child.expect_exact(self.PYTHON_PROMPT) ++ ++ def test_python_interpreter_echo(self): ++ """Test that that the user typed commands is echoed to stdout""" ++ ++ self.launch(use_colors=False, dimensions=(100, 100)) ++ ++ # Enter the python interpreter. ++ self.verify_command_echo( ++ "script --language python --", expected_output="Python.*\\.", is_regex=True ++ ) ++ self.child_in_script_interpreter = True ++ ++ self.verify_command_echo("val = 300") ++ self.verify_command_echo( ++ "print('result =', 300)", expected_output="result = 300" ++ ) +diff --git a/lldb/test/Shell/ScriptInterpreter/Python/io.test b/lldb/test/Shell/ScriptInterpreter/Python/io.test +new file mode 100644 +index 0000000000000..25e3de41724e0 +--- /dev/null ++++ b/lldb/test/Shell/ScriptInterpreter/Python/io.test +@@ -0,0 +1,12 @@ ++# RUN: rm -rf %t.stdout %t.stderr ++# RUN: cat %s | %lldb --script-language python > %t.stdout 2> %t.stderr ++# RUN: cat %t.stdout | FileCheck %s --check-prefix STDOUT ++# RUN: cat %t.stderr | FileCheck %s --check-prefix STDERR ++script ++variable = 300 ++print(variable) ++print(not_value) ++quit ++ ++# STDOUT: 300 ++# STDERR: NameError{{.*}}is not defined diff --git a/llvm.spec b/llvm.spec index 1385227..1d4e491 100644 --- a/llvm.spec +++ b/llvm.spec @@ -2,7 +2,7 @@ #region version %global maj_ver 21 %global min_ver 1 -%global patch_ver 7 +%global patch_ver 8 #global rc_ver rc3 %bcond_with snapshot_build @@ -34,7 +34,6 @@ %define bcond_override_default_libcxx 0 %define bcond_override_default_lto_build 0 %define bcond_override_default_check 0 -%define _find_debuginfo_dwz_opts %{nil} %endif # Build compat packages llvmN instead of main package for the current LLVM @@ -42,7 +41,7 @@ %bcond_with compat_build # Bundle compat libraries for a previous LLVM version, as part of llvm-libs and # clang-libs. Used on RHEL. -%bcond_without bundle_compat_lib +%bcond_with bundle_compat_lib %bcond_without check %if %{with bundle_compat_lib} @@ -186,16 +185,6 @@ end %endif %endif -# We only want to run the performance comparison on snapshot builds. -# centos-streams/RHEL do not have all the requirements. We tried to use pip, -# but we've seen issues on some architectures. We're now restricting this -# to Fedora. -%if %{with pgo} && %{with snapshot_build} && %{defined fedora} -%global run_pgo_perf_comparison 1 -%else -%global run_pgo_perf_comparison %{nil} -%endif - # Sanity checks for PGO and bootstrapping #---------------------------------------- %if %{with pgo} @@ -406,12 +395,6 @@ end %global pkg_name_polly polly%{pkg_suffix} #endregion polly globals -#region PGO globals -%if 0%{run_pgo_perf_comparison} -%global llvm_test_suite_dir %{_datadir}/llvm-test-suite -%endif -#endregion PGO globals - #region flang globals %global pkg_name_flang flang%{pkg_suffix} #endregion flang globals @@ -503,11 +486,13 @@ Patch2003: 0001-cmake-Resolve-symlink-when-finding-install-prefix.patch #region LLD patches Patch106: 0001-19-Always-build-shared-libs-for-LLD.patch +Patch2103: 0001-lld-Adjust-compressed-debug-level-test-for-s390x-wit.patch #endregion LLD patches #region polly patches Patch2102: 0001-20-polly-shared-libs.patch Patch2202: 0001-22-polly-shared-libs.patch +Patch2302: 0001-22-polly-shared-libs.patch #endregion polly patches #region RHEL patches @@ -542,6 +527,15 @@ Patch2006: 0001-Add-REQUIRES-asserts-to-test-added-in-145149-because.patch Patch2101: 0001-clang-Add-a-hack-to-fix-the-offload-build-with-the-m.patch Patch2201: 0001-clang-Add-a-hack-to-fix-the-offload-build-with-the-m.patch +# Fix segfault compiling plotters rust crate on ppc64le +Patch2104: 0001-PowerPC-Add-check-for-cast-when-shufflevector-172443.patch + +# Fix for lldb python shell with python 3.14 (rbhz#2428608) +Patch2105: 43cb4631c1f42dbfce78288b8ae30b5840ed59b3.patch + +# Fix for s390x vector miscompilation (rhbz#2430017) +Patch2106: 0001-SystemZ-Fix-code-in-widening-vector-multiplication-1.patch + %if 0%{?rhel} == 8 %global python3_pkgversion 3.12 %global __python3 /usr/bin/python3.12 @@ -585,20 +579,6 @@ BuildRequires: compiler-rt BuildRequires: llvm %endif -%if 0%{run_pgo_perf_comparison} -BuildRequires: llvm-test-suite -BuildRequires: tcl-devel -BuildRequires: which -# pandas and scipy are needed for running llvm-test-suite/utils/compare.py -# For RHEL we have to install it from pip and for fedora we take the RPM package. -%if 0%{?rhel} -BuildRequires: python3-pip -%else -BuildRequires: python3-pandas -BuildRequires: python3-scipy -%endif -%endif - %else %if %{with use_lld} BuildRequires: lld @@ -1489,11 +1469,9 @@ export ASMFLAGS="%{build_cflags}" # We set CLANG_DEFAULT_PIE_ON_LINUX=OFF and PPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON to match the # defaults used by Fedora's GCC. -# Disable dwz on aarch64, because it takes a huge amount of time to decide not to optimize things. -# This is copied from clang. -%ifarch aarch64 +# Disable dwz because it takes a huge amount of time to decide not to +# optimize things. %define _find_debuginfo_dwz_opts %{nil} -%endif cd llvm @@ -1503,10 +1481,6 @@ OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" OLD_CWD="$PWD" %global builddir_instrumented $RPM_BUILD_DIR/instrumented-llvm -%if 0%{run_pgo_perf_comparison} -%global builddir_perf_pgo $RPM_BUILD_DIR/performance-of-pgoed-clang -%global builddir_perf_system $RPM_BUILD_DIR/performance-of-system-clang -%endif #region LLVM lit %if %{with python_lit} @@ -1547,6 +1521,32 @@ popd -DLLVM_ENABLE_EH=ON %endif +%if 0%{?rhel} == 8 +# On RHEL 8 we build with gcc, but the runtimes are built with the just built +# clang, so we need to pass clang supported compiler flags to the runtimes +# build. If we pass the gcc flags, some of the cmake feature checkes will +# fail, because they use -Werror and emit an error when passed gcc specific +# compiler flags like -specs. +# Specifically, this is required in order to fix the libomptest.so build. + +function strip_specs { + echo $1 | sed -e 's/-specs=[^ ]\+//g' +} + +CLANG_CC_CONFIG=$(pwd)/redhat-hardened-clang.cfg +CLANG_LD_CONFIG=$(pwd)/redhat-hardened-clang-ld.cfg +echo "-fPIE" >> $CLANG_CC_CONFIG +echo "-pie" >> $CLANG_LD_CONFIG +CLANG_CCFLAGS_EXTRA=--config=$CLANG_CC_CONFIG +CLANG_LDFLAGS_EXTRA=--config=$CLANG_LD_CONFIG + +CLANG_CXXFLAGS=$(strip_specs "$CXXFLAGS $CLANG_CCFLAGS_EXTRA") +CLANG_CFLAGS=$(strip_specs "$CFLAGS $CLANG_CCFLAGS_EXTRA") +CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA") +%global cmake_common_args %{cmake_common_args} \\\ + -DRUNTIMES_CMAKE_ARGS="-DCMAKE_C_FLAGS=$CLANG_C_FLAGS;-DCMAKE_CXX_FLAGS=$CLANG_CXX_FLAGS;-DCMAKE_SHARED_LINKER_FLAGS=$CLANG_LD_FLAGS" +%endif + %if %reduce_debuginfo == 1 %global cmake_common_args %{cmake_common_args} -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" %global cmake_common_args %{cmake_common_args} -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" @@ -1886,6 +1886,10 @@ llvm-profdata show --topn=10 %{builddir_instrumented}/tools/clang/utils/perf-tra cp %{builddir_instrumented}/tools/clang/utils/perf-training/clang.profdata $RPM_BUILD_DIR/result.profdata +# The instrumented files are not needed anymore. +# Remove them in order to free disk space (~10GiB). +rm -rf %{builddir_instrumented} + #endregion Perf training %endif @@ -1963,71 +1967,17 @@ cd $OLD_CWD %cmake_build --target runtimes #endregion Final stage -#region Performance comparison -%if 0%{run_pgo_perf_comparison} - -function run_perf_test { - local build_dir=$1 - - cd %{llvm_test_suite_dir} - %__cmake -G Ninja \ - -S "%{llvm_test_suite_dir}" \ - -B "${build_dir}" \ - -DCMAKE_GENERATOR=Ninja \ - -DCMAKE_C_COMPILER=clang \ - -DCMAKE_CXX_COMPILER=clang++ \ - -DTEST_SUITE_BENCHMARKING_ONLY=ON \ - -DTEST_SUITE_COLLECT_STATS=ON \ - -DTEST_SUITE_USE_PERF=OFF \ - -DTEST_SUITE_SUBDIRS=CTMark \ - -DTEST_SUITE_RUN_BENCHMARKS=OFF \ - -DTEST_SUITE_COLLECT_CODE_SIZE=OFF \ - -C%{llvm_test_suite_dir}/cmake/caches/O3.cmake - - # Build the test-suite - %__cmake --build "${build_dir}" -j1 --verbose - - # Run the tests with lit: - %{builddir_instrumented}/bin/llvm-lit -v -o ${build_dir}/results.json ${build_dir} || true - cd $OLD_CWD -} - -# Run performance test for system clang -reset_paths -run_perf_test %{builddir_perf_system} - -# Run performance test for PGOed clang -reset_paths -FINAL_BUILD_DIR=`pwd`/%{_vpath_builddir} -export LD_LIBRARY_PATH="${FINAL_BUILD_DIR}/lib:${FINAL_BUILD_DIR}/lib64:${LD_LIBRARY_PATH}" -export PATH="${FINAL_BUILD_DIR}/bin:${OLD_PATH}" -run_perf_test %{builddir_perf_pgo} - -# Compare the performance of system and PGOed clang -%if 0%{?rhel} -python3 -m venv compare-env -source ./compare-env/bin/activate -pip install "pandas>=2.2.3" -pip install "scipy>=1.13.1" -MY_PYTHON_BIN=./compare-env/bin/python3 +%if %{with lto_build} +# The LTO cache is not needed anymore. +# Remove it in order to free disk space. +rm -rfv %{_vpath_builddir}/lto.cache %endif -system_llvm_release=$(/usr/bin/clang --version | grep -Po '[0-9]+\.[0-9]+\.[0-9]' | head -n1) -${MY_PYTHON_BIN} %{llvm_test_suite_dir}/utils/compare.py \ - --metric compile_time \ - --lhs-name ${system_llvm_release} \ - --rhs-name pgo-%{version} \ - %{builddir_perf_system}/results.json vs %{builddir_perf_pgo}/results.json > %{builddir_perf_pgo}/results-system-vs-pgo.txt || true - -echo "Result of Performance comparison between system and PGOed clang" -cat %{builddir_perf_pgo}/results-system-vs-pgo.txt - -%if 0%{?rhel} -# Deactivate virtual python environment created ealier -deactivate -%endif -%endif -#endregion Performance comparison +# Strip debug info from static libraries before the install phase because +# LLVM already consumes a lot of disk space (i.e. > 150GiB). +# The install phase duplicates files on disk, causing errors if the disk is +# too small. +RPM_BUILD_ROOT=$(realpath ..)/%{build_libdir} %__brp_strip_static_archive #region compat lib cd .. @@ -2171,9 +2121,6 @@ ln -s ../share/clang/clang-format-diff.py %{buildroot}%{install_bindir}/clang-fo # Install the PGO profile that was used to build this LLVM into the clang package %if 0%{with pgo} cp -v $RPM_BUILD_DIR/result.profdata %{buildroot}%{install_datadir}/llvm-pgo.profdata -%if 0%{run_pgo_perf_comparison} -cp -v %{builddir_perf_pgo}/results-system-vs-pgo.txt %{buildroot}%{install_datadir}/results-system-vs-pgo.txt -%endif %endif # File in the macros file for other packages to use. We are not doing this @@ -3377,9 +3324,6 @@ fi %if 0%{with pgo} %{expand_datas %{expand: llvm-pgo.profdata }} -%if 0%{run_pgo_perf_comparison} -%{expand_datas %{expand: results-system-vs-pgo.txt }} -%endif %endif diff --git a/sources b/sources index 4f012ca..9ed6b4f 100644 --- a/sources +++ b/sources @@ -1,4 +1,2 @@ -SHA512 (llvm-project-20.1.8.src.tar.xz) = f330e72e6a1da468569049437cc0ba7a41abb816ccece7367189344f7ebfef730f4788ac7af2bef0aa8a49341c15ab1d31e941ffa782f264d11fe0dc05470773 -SHA512 (llvm-project-20.1.8.src.tar.xz.sig) = d74369bdb4d1b82775161ea53c9c5f3a23ce810f4df5ff617123023f9d8ce720e7d6ecc9e17f8ebd39fd9e7a9de79560abdf2ffe73bcb907a43148d43665d619 -SHA512 (llvm-project-21.1.7.src.tar.xz) = ae30a53ed929df979849f7433bf705bc3d540aa9e12a02a175eb2483d1a56f9ca1203c9b67795f6e84cf2407c28d46d5d5351b290d8735adb5206103fee6f379 -SHA512 (llvm-project-21.1.7.src.tar.xz.sig) = d02b09c77abd537eb24d6d43470f962c80a9ec6ccc03ac0efc950d90dbdec5b94dd6abad18143890ff85cee2bdeb7bcf1dac2a576ffcab8ef053d8526417bdcc +SHA512 (llvm-project-21.1.8.src.tar.xz) = cae4c44e7bf678071723da63ad5839491d717a7233e7f4791aa408207f3ea42f52de939ad15189b112c02a0770f1bb8d59bae6ad31ef53417a6eea7770fe52ab +SHA512 (llvm-project-21.1.8.src.tar.xz.sig) = 10f58eff58ed6e701d0f123b15e68c82ab8cbdf99b1c86c0d83e3b8553e90ea51055e30327e8e442ded57c8f503e2a2de9ee075e9c28b5ba815a0f8922f8671c