-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Reland "[SelectionDAG] Introducing a new ISD::POISON SDNode to represent the poison value in the IR." #135056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-aarch64 @llvm/pr-subscribers-llvm-selectiondag Author: zhijian lin (diggerlin) ChangesThe PR fix a assert on the PR #125883 Full diff: https://github.com/llvm/llvm-project/pull/135056.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 5ed83060e150e..6493e0e6583f0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -165,6 +165,7 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
case ISD::STRICT_UINT_TO_FP:
case ISD::SINT_TO_FP:
case ISD::UINT_TO_FP: R = SoftenFloatRes_XINT_TO_FP(N); break;
+ case ISD::POISON:
case ISD::UNDEF: R = SoftenFloatRes_UNDEF(N); break;
case ISD::VAARG: R = SoftenFloatRes_VAARG(N); break;
case ISD::VECREDUCE_FADD:
diff --git a/llvm/test/CodeGen/RISCV/pr125883.ll b/llvm/test/CodeGen/RISCV/pr125883.ll
new file mode 100644
index 0000000000000..f2da05c660be6
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/pr125883.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s -mtriple=riscv32 | FileCheck %s
+
+define void @b(ptr %p1) {
+; CHECK: .cfi_startproc
+; CHECK-NEXT: # %bb.0: # %entry
+; CHECK-NEXT: sb zero, 7(a0)
+; CHECK-NEXT: sb zero, 6(a0)
+; CHECK-NEXT: sb zero, 5(a0)
+; CHECK-NEXT: sb a0, 4(a0)
+; CHECK-NEXT: sb zero, 3(a0)
+; CHECK-NEXT: sb zero, 2(a0)
+; CHECK-NEXT: sb zero, 1(a0)
+; CHECK-NEXT: sb a0, 0(a0)
+; CHECK-NEXT: ret
+
+entry:
+ store volatile double poison, ptr %p1, align 1
+ ret void
+}
|
The title of this PR does not follow established conventions for commits in LLVM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please also fix other cases in this file? Like SoftPromoteHalfRes for example.
Done
llvm/test/CodeGen/RISCV/pr135056.ll
Outdated
@@ -0,0 +1,19 @@ | |||
; RUN: llc < %s -mtriple=riscv32 | FileCheck %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect filename - prXXXXX.ll is for Problem Reports (a very old name) - which now map to issue numbers - don't use pull request numbers here
I do not think there is an issue the fix, Can I use PR125883?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diggerlin you seem to have edited Simon's message instead of replying.
You should try to give a descriptive name. Like poison-legalization.ll
Title should be what it functionally fixes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't fix the downstream crash I reported in #125883 (comment)
The reported crash came from |
llvm/test/CodeGen/RISCV/pr135056.ll
Outdated
entry: | ||
store volatile double poison, ptr %p1, align 1 | ||
ret void | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test vector cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test vector cases?
I do not think we need a vector test case, The test case has cover the code we changed.
llvm/test/CodeGen/RISCV/pr135056.ll
Outdated
; CHECK-NEXT: ret | ||
|
||
entry: | ||
store volatile double poison, ptr %p1, align 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unaligned store not necessary for the test?
can you give me the reproduce test case , I will add the test case into the PR. |
Shouldn't that just be the same test case but with "half"? |
Can you help to try it now ? @kuhar |
define void @b(ptr %p1, ptr %p2) { | ||
; CHECK: .cfi_startproc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define void @b(ptr %p1, ptr %p2) { | |
; CHECK: .cfi_startproc | |
define void @b(ptr %p1, ptr %p2) nounwind { |
That should remove the .cfi_startproc.
Also I'd suggest one function for each type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using update_llc_test_checks.py (and adding nounwind to ensure it doesn't add the cfi information), otherwise this change LGTM.
But since I'm not a SelectionDAG expert please wait for someone else to approve too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this.
Now that the base PR is reverted, can you pull in the original change from #125883 to reland this?
I think we can revert your revert commit and then land the PR after the PR approved. |
Reverting the revert would get us back into a broken state. We should reland the original PR with this fix as one commit. |
…poison value in the IR. (llvm#125883) A new ISD::POISON SDNode is introduced to represent the `poison value` in the IR, replacing the previous use of ISD::UNDEF.
7087edb
to
781c794
Compare
I updated the patch with the original PR (#125883) and the fix for " [DAGTypeLegalize] Legalize ISD::POISON as ISD::UNDEF for Float Type Legalization" , and change the title and summary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the RISC-V crash we observed with the first version of the patch. Thanks for taking care of this!
Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
…ent the poison value in the IR." (llvm#135056) A new ISD::POISON SDNode is introduced to represent the poison value in the IR, replacing the previous use of ISD::UNDEF
FYI, for reference, I've bisected a very elusive and tricky crash down to this commit, when compiling with Clang on Windows/arm64. Unfortunately the crash isn't fully deterministic and seems dependent on what version of Clang I'm using to build Clang, so it's not clear cut what's the root cause. But posting here in case someone else also investigates and looks at bisects that point at this commit. |
Sorry for the noise; this commit was unrelated to the issue. (This commit only uncovered the bug that had been present for a couple weeks before.) |
A new ISD::POISON SDNode is introduced to represent the poison value in the IR, replacing the previous use of ISD::UNDEF