-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[CodeGen] This patch fix a bug that may caused error for a self-defined target in SelectionDAG::getNode #75320
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
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-selectiondag Author: yan zhou (zhou3968322) Changeswe need first judge N1.getNumOperands() > 0. If Lowering Generated SDNode like.
will cause a error. Full diff: https://github.com/llvm/llvm-project/pull/75320.diff 1 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 5be1892a44f6dd..5720d001d2e337 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6858,8 +6858,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
// expanding copies of large vectors from registers. This only works for
// fixed length vectors, since we need to know the exact number of
// elements.
- if (N2C && N1.getOperand(0).getValueType().isFixedLengthVector() &&
- N1.getOpcode() == ISD::CONCAT_VECTORS && N1.getNumOperands() > 0) {
+ if (N2C && N1.getNumOperands() > 0 &&
+ N1.getOperand(0).getValueType().isFixedLengthVector() &&
+ N1.getOpcode() == ISD::CONCAT_VECTORS) {
unsigned Factor =
N1.getOperand(0).getValueType().getVectorNumElements();
return getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT,
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
15f1c5e
to
7d06547
Compare
This looks OK by inspection, but do you have a test case you could add as well? |
No, for current targets, there is no dag SDNode like this:
It only generated a v2i32 with no input operands. But I think this is only an internal change and does not affect other modules. |
7a9c52d
to
632822c
Compare
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.
LGTM - cheers
first judage N1.getOpCode() == ISD::CONCAT_VECTORS may be better. If Lowering Generated SDNode like. v2i32 t20: TargetOpNode. i32 t21: extract_vector_elt t20 0. will cause a error.
632822c
to
82947ae
Compare
@arsenm , no commit access, can you commit it on my behalf? |
I guess this is broken by this patch https://lab.llvm.org/buildbot/#/builders/238/builds/7108 |
Why do you suspect this patch? |
No PPC related patches |
That was my guess, and it was wrong. Local bisect shows f568763 |
we need first judge N1.getNumOperands() > 0.
If Lowering Generated SDNode like.
will cause a error.