[llvm] 2484680 - Add non-null check before accessing pointer (#83459)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 21:01:37 PST 2024
Author: Martin Wehking
Date: 2024-03-07T10:31:34+05:30
New Revision: 248468097faa9739ae66ff6fe1836e529d58455a
URL: https://github.com/llvm/llvm-project/commit/248468097faa9739ae66ff6fe1836e529d58455a
DIFF: https://github.com/llvm/llvm-project/commit/248468097faa9739ae66ff6fe1836e529d58455a.diff
LOG: Add non-null check before accessing pointer (#83459)
Add a check if RC is not null to ensure that a consecutive access is
safe.
A static analyzer flagged this issue since hasVectorRegisters
potentially dereferences RC.
Added:
Modified:
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index 634b4aeb30a730..cb448aaafa4c08 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -1054,6 +1054,7 @@ void SIFoldOperands::foldOperand(
// Don't fold if OpToFold doesn't hold an aligned register.
const TargetRegisterClass *RC =
TRI->getRegClassForReg(*MRI, OpToFold.getReg());
+ assert(RC);
if (TRI->hasVectorRegisters(RC) && OpToFold.getSubReg()) {
unsigned SubReg = OpToFold.getSubReg();
if (const TargetRegisterClass *SubRC =
More information about the llvm-commits
mailing list