Skip to content

Commit 2484680

Browse files
author
Martin Wehking
authored
Add non-null check before accessing pointer (llvm#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.
1 parent 2fcf248 commit 2484680

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/Target/AMDGPU/SIFoldOperands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ void SIFoldOperands::foldOperand(
10541054
// Don't fold if OpToFold doesn't hold an aligned register.
10551055
const TargetRegisterClass *RC =
10561056
TRI->getRegClassForReg(*MRI, OpToFold.getReg());
1057+
assert(RC);
10571058
if (TRI->hasVectorRegisters(RC) && OpToFold.getSubReg()) {
10581059
unsigned SubReg = OpToFold.getSubReg();
10591060
if (const TargetRegisterClass *SubRC =

0 commit comments

Comments
 (0)