[llvm] Add non-null check before accessing pointer (PR #83459)
Martin Wehking via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 1 05:30:46 PST 2024
================
@@ -1054,7 +1054,7 @@ void SIFoldOperands::foldOperand(
// Don't fold if OpToFold doesn't hold an aligned register.
const TargetRegisterClass *RC =
TRI->getRegClassForReg(*MRI, OpToFold.getReg());
- if (TRI->hasVectorRegisters(RC) && OpToFold.getSubReg()) {
+ if (RC && TRI->hasVectorRegisters(RC) && OpToFold.getSubReg()) {
----------------
MartinWehking wrote:
Is `getRegClassForReg` always returning a non-null pointer for every possible context?
When looking at the body of the function:
`return Reg.isVirtual() ? MRI.getRegClass(Reg) : getPhysRegBaseClass(Reg); `
I spotted that getPhysRegBaseClass(Reg) might return a nullptr.
https://github.com/llvm/llvm-project/pull/83459
More information about the llvm-commits
mailing list