Skip to content

Commit 4cbd86e

Browse files
authored
Merge pull request uxlfoundation#808 from hvdijk/dpcpp-riscv-sycl-cts-patch
Add LLVM patch to DPC++ to fix crashes on RISC-V.
2 parents 95bbe36 + 4c1d7c9 commit 4cbd86e

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
From 630c2f8fd12c5e0a14196cabbacb1fac26c14bd5 Mon Sep 17 00:00:00 2001
2+
From: zhijian lin <zhijian@ca.ibm.com>
3+
Date: Thu, 10 Apr 2025 11:29:14 -0400
4+
Subject: [PATCH] Revert "[SelectionDAG] Introducing a new ISD::POISON SDNode
5+
to represent the poison value in the IR." (#135060)
6+
7+
Reverts llvm/llvm-project#125883
8+
9+
This PR causes crashes in RISC-V codegen around f16/f64 poison values:
10+
https://github.com/llvm/llvm-project/pull/125883#issuecomment-2787048206
11+
12+
Reland "[SelectionDAG] Introducing a new ISD::POISON SDNode to represent the poison value in the IR." (#135056)
13+
14+
A new ISD::POISON SDNode is introduced to represent the poison value in
15+
the IR, replacing the previous use of ISD::UNDEF
16+
---
17+
.../SelectionDAG/LegalizeFloatTypes.cpp | 3 +++
18+
.../CodeGen/PowerPC/poison-legalization.ll | 11 +++++++++
19+
.../test/CodeGen/RISCV/poison-legalization.ll | 24 +++++++++++++++++++
20+
3 files changed, 38 insertions(+)
21+
create mode 100644 llvm/test/CodeGen/PowerPC/poison-legalization.ll
22+
create mode 100644 llvm/test/CodeGen/RISCV/poison-legalization.ll
23+
24+
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
25+
index 5ed83060e150..432209e8ecb0 100644
26+
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
27+
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
28+
@@ -165,6 +165,7 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
29+
case ISD::STRICT_UINT_TO_FP:
30+
case ISD::SINT_TO_FP:
31+
case ISD::UINT_TO_FP: R = SoftenFloatRes_XINT_TO_FP(N); break;
32+
+ case ISD::POISON:
33+
case ISD::UNDEF: R = SoftenFloatRes_UNDEF(N); break;
34+
case ISD::VAARG: R = SoftenFloatRes_VAARG(N); break;
35+
case ISD::VECREDUCE_FADD:
36+
@@ -1501,6 +1502,7 @@ void DAGTypeLegalizer::ExpandFloatResult(SDNode *N, unsigned ResNo) {
37+
report_fatal_error("Do not know how to expand the result of this "
38+
"operator!");
39+
// clang-format off
40+
+ case ISD::POISON:
41+
case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi); break;
42+
case ISD::SELECT: SplitRes_Select(N, Lo, Hi); break;
43+
case ISD::SELECT_CC: SplitRes_SELECT_CC(N, Lo, Hi); break;
44+
@@ -3319,6 +3321,7 @@ void DAGTypeLegalizer::SoftPromoteHalfResult(SDNode *N, unsigned ResNo) {
45+
case ISD::STRICT_UINT_TO_FP:
46+
case ISD::SINT_TO_FP:
47+
case ISD::UINT_TO_FP: R = SoftPromoteHalfRes_XINT_TO_FP(N); break;
48+
+ case ISD::POISON:
49+
case ISD::UNDEF: R = SoftPromoteHalfRes_UNDEF(N); break;
50+
case ISD::ATOMIC_SWAP: R = BitcastToInt_ATOMIC_SWAP(N); break;
51+
case ISD::VECREDUCE_FADD:
52+
diff --git a/llvm/test/CodeGen/PowerPC/poison-legalization.ll b/llvm/test/CodeGen/PowerPC/poison-legalization.ll
53+
new file mode 100644
54+
index 000000000000..579130180a66
55+
--- /dev/null
56+
+++ b/llvm/test/CodeGen/PowerPC/poison-legalization.ll
57+
@@ -0,0 +1,11 @@
58+
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s
59+
+
60+
+define void @ExpandFloat(ptr %p1 ) {
61+
+; CHECK: stfd 0, 8(3)
62+
+; CHECK-NEXT: stfd 0, 0(3)
63+
+; CHECK-NEXT: blr
64+
+entry:
65+
+ store volatile ppc_fp128 poison, ptr %p1
66+
+ ret void
67+
+}
68+
+
69+
diff --git a/llvm/test/CodeGen/RISCV/poison-legalization.ll b/llvm/test/CodeGen/RISCV/poison-legalization.ll
70+
new file mode 100644
71+
index 000000000000..f0954b74e937
72+
--- /dev/null
73+
+++ b/llvm/test/CodeGen/RISCV/poison-legalization.ll
74+
@@ -0,0 +1,24 @@
75+
+; RUN: llc < %s -mtriple=riscv32 | FileCheck %s
76+
+
77+
+define void @SoftenFloat(ptr %p1) {
78+
+; CHECK-LABEL: SoftenFloat:
79+
+; CHECK: # %bb.0: # %entry
80+
+; CHECK-NEXT: sw a0, 4(a0)
81+
+; CHECK-NEXT: sw a0, 0(a0)
82+
+; CHECK-NEXT: ret
83+
+
84+
+entry:
85+
+ store volatile double poison, ptr %p1
86+
+ ret void
87+
+}
88+
+
89+
+define void @PromoteHalf(ptr %p1 ) {
90+
+; CHECK-LABEL: PromoteHalf:
91+
+; CHECK: # %bb.0: # %entry
92+
+; CHECK-NEXT: sh a0, 0(a0)
93+
+; CHECK-NEXT: ret
94+
+entry:
95+
+ store volatile half poison, ptr %p1
96+
+ ret void
97+
+}
98+
+
99+
--
100+
2.47.2
101+

0 commit comments

Comments
 (0)