Skip to content

Commit b0e05a5

Browse files
mikhailramalholukel97
authored andcommitted
[RISCV] Add missing check before accessing pointer
C2 can be null here, so we need to check it or clang may crash.
1 parent 83c1d00 commit b0e05a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18385,7 +18385,7 @@ bool RISCVTargetLowering::isDesirableToCommuteWithShift(
1838518385
auto *C2 = dyn_cast<ConstantSDNode>(N->getOperand(1));
1838618386

1838718387
// Bail if we might break a sh{1,2,3}add pattern.
18388-
if (Subtarget.hasStdExtZba() && C2->getZExtValue() >= 1 &&
18388+
if (Subtarget.hasStdExtZba() && C2 && C2->getZExtValue() >= 1 &&
1838918389
C2->getZExtValue() <= 3 && N->hasOneUse() &&
1839018390
N->user_begin()->getOpcode() == ISD::ADD &&
1839118391
!isUsedByLdSt(*N->user_begin(), nullptr) &&

0 commit comments

Comments
 (0)