From: Akshay Khadse Date: Sat, 15 Apr 2023 03:28:50 +0000 (+0800) Subject: Guard against dereferencing a nullptr X-Git-Tag: upstream/17.0.6~11521 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=842dc35fc93203751047490f2989360b15ea67d1;p=platform%2Fupstream%2Fllvm.git Guard against dereferencing a nullptr In `lib/CodeGen/PrologEpilogInserter.cpp` file, `RS` is assigned via `RS = TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : nullptr;`. This means that `RS` can be `nullptr`. While executing the `TFI->processFunctionBeforeFrameFinalized(MF, RS);`, the `RS` can be dereferenced in the call `RS->enterBasicBlock(MBB);` in file `lib/Target/AMDGPU/SIFrameLowering.cpp` Reviewed By: skan, arsenm Differential Revision: https://reviews.llvm.org/D146791 --- diff --git a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp index c2bc959..3e45d33 100644 --- a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp @@ -1350,6 +1350,7 @@ void SIFrameLowering::processFunctionBeforeFrameFinalized( TII->getNamedOperand(MI, AMDGPU::OpName::vdata)->getReg(); if (FuncInfo->allocateVGPRSpillToAGPR(MF, FI, TRI->isAGPR(MRI, VReg))) { + assert(RS != nullptr); // FIXME: change to enterBasicBlockEnd() RS->enterBasicBlock(MBB); TRI->eliminateFrameIndex(MI, 0, FIOp, RS);