Compare commits
No commits in common. "c8-stream-rhel8" and "c9-beta" have entirely different histories.
c8-stream-
...
c9-beta
@ -1,137 +0,0 @@
|
||||
From 98b82f90dfb7865ae4dbfcb5a83a9e817e7894a1 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Per <kevin.per@protonmail.com>
|
||||
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<ShuffleVectorSDNode>(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<ShuffleVectorSDNode>(Res))
|
||||
+ return Res;
|
||||
+
|
||||
Mask = cast<ShuffleVectorSDNode>(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> <i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 2, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
|
||||
+ %shuffle56 = shufflevector <32 x i32> %vecinit37, <32 x i32> %BS_ARG_1, <32 x i32> <i32 4, i32 9, i32 3, i32 3, i32 4, i32 1, i32 1, i32 0, i32 16, i32 5, i32 5, i32 34, i32 3, i32 0, i32 8, i32 2, i32 8, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 7, i32 5, i32 3, i32 6, i32 0, i32 3, i32 4, i32 7>
|
||||
+ ret <32 x i32> %shuffle56
|
||||
+}
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@ -1,191 +0,0 @@
|
||||
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> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
|
||||
+ %zext1 = zext <8 x i8> %shuf1 to <8 x i16>
|
||||
+ %shuf2 = shufflevector <16 x i8> %val2, <16 x i8> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
|
||||
+ %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> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
|
||||
+ %sext1 = sext <8 x i8> %shuf1 to <8 x i16>
|
||||
+ %shuf2 = shufflevector <16 x i8> %val2, <16 x i8> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
|
||||
+ %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> <i32 0, i32 1, i32 2, i32 3>
|
||||
+ %zext1 = zext <4 x i16> %shuf1 to <4 x i32>
|
||||
+ %shuf2 = shufflevector <8 x i16> %val2, <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
||||
+ %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> <i32 0, i32 1, i32 2, i32 3>
|
||||
+ %sext1 = sext <4 x i16> %shuf1 to <4 x i32>
|
||||
+ %shuf2 = shufflevector <8 x i16> %val2, <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
||||
+ %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> <i32 0, i32 1>
|
||||
+ %zext1 = zext <2 x i32> %shuf1 to <2 x i64>
|
||||
+ %shuf2 = shufflevector <4 x i32> %val2, <4 x i32> poison, <2 x i32> <i32 0, i32 1>
|
||||
+ %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> <i32 0, i32 1>
|
||||
+ %sext1 = sext <2 x i32> %shuf1 to <2 x i64>
|
||||
+ %shuf2 = shufflevector <4 x i32> %val2, <4 x i32> poison, <2 x i32> <i32 0, i32 1>
|
||||
+ %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
|
||||
|
||||
@ -1,276 +0,0 @@
|
||||
From 43cb4631c1f42dbfce78288b8ae30b5840ed59b3 Mon Sep 17 00:00:00 2001
|
||||
From: Ebuka Ezike <yerimyah1@gmail.com>
|
||||
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
|
||||
1196
SPECS/llvm.spec
1196
SPECS/llvm.spec
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user