[llvm] [RISCV] Add missing check before accessing pointer (PR #121816)
Mikhail R. Gadelha via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 10:42:23 PST 2025
https://github.com/mikhailramalho created https://github.com/llvm/llvm-project/pull/121816
C2 can be null here, so we need to check it or clang may crash.
>From 948927e7998528b68378e4678bfbbf13dca3cdba Mon Sep 17 00:00:00 2001
From: "Mikhail R. Gadelha" <mikhail at igalia.com>
Date: Mon, 6 Jan 2025 15:39:46 -0300
Subject: [PATCH] [RISCV] Add missing check before accessing pointer
C2 can be null here, so we need to check it or clang may crash.
---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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) &&
More information about the llvm-commits
mailing list