Skip to content

[RISCV] Added test case for PR119527. NFC #121816

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

Merged
merged 9 commits into from
Jan 7, 2025

Conversation

mikhailramalho
Copy link
Member

C2 can be null here, so we need to check it or clang may crash.

@llvmbot
Copy link
Member

llvmbot commented Jan 6, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Mikhail R. Gadelha (mikhailramalho)

Changes

C2 can be null here, so we need to check it or clang may crash.


Full diff: https://github.com/llvm/llvm-project/pull/121816.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+1-1)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 7efe3732d8be13..9acd374225505d 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -18388,7 +18388,7 @@ bool RISCVTargetLowering::isDesirableToCommuteWithShift(
     auto *C2 = dyn_cast<ConstantSDNode>(N->getOperand(1));
 
     // Bail if we might break a sh{1,2,3}add pattern.
-    if (Subtarget.hasStdExtZba() && C2->getZExtValue() >= 1 &&
+    if (Subtarget.hasStdExtZba() && C2 && C2->getZExtValue() >= 1 &&
         C2->getZExtValue() <= 3 && N->hasOneUse() &&
         N->user_begin()->getOpcode() == ISD::ADD &&
         !isUsedByLdSt(*N->user_begin(), nullptr) &&

@mikhailramalho
Copy link
Member Author

creduce is running now to reduce the test case I got, I'll add the test case as soon as it's done.

Copy link
Contributor

@lukel97 lukel97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM w/ Philip's comment about moving the test

@lukel97
Copy link
Contributor

lukel97 commented Jan 7, 2025

Since a bunch of people were running into this crash I've cherry-picked the RISCVISelLowering.cpp changes to main in b0e05a5, but it still needs the test case from this PR

Signed-off-by: Mikhail R. Gadelha <[email protected]>
Copy link
Contributor

@lukel97 lukel97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM again, just need to update the PR title to reflect that it's adding a test and it's NFC

Copy link
Collaborator

@preames preames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w/minor comment. (I second Luke's comment on the change to description.)

@mikhailramalho mikhailramalho changed the title [RISCV] Add missing check before accessing pointer [RISCV] Added test case for PR119527. NFC Jan 7, 2025
@mikhailramalho mikhailramalho merged commit 51c9c82 into llvm:main Jan 7, 2025
5 of 6 checks passed
@mikhailramalho mikhailramalho deleted the fix-c2 branch January 7, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants