Skip to content

Commit c5177f1

Browse files
author
Martin Wehking
authored
Silence potential overflow warning (#83272)
Cast Offset variable to int64_t type directly inside a multiplication and function call to utilize 64-bit arithmetic. Ensure that the multiplication will not overflow. A static analyzer warned about this since the function expects a 64-bit argument, but the multiplication is evaluated inside a 32-bit context.
1 parent 09bc6ab commit c5177f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,12 +1753,12 @@ void SIRegisterInfo::buildVGPRSpillLoadStore(SGPRSpillBuilder &SB, int Index,
17531753
unsigned Opc = ST.enableFlatScratch() ? AMDGPU::SCRATCH_LOAD_DWORD_SADDR
17541754
: AMDGPU::BUFFER_LOAD_DWORD_OFFSET;
17551755
buildSpillLoadStore(*SB.MBB, SB.MI, SB.DL, Opc, Index, SB.TmpVGPR, false,
1756-
FrameReg, Offset * SB.EltSize, MMO, SB.RS);
1756+
FrameReg, (int64_t)Offset * SB.EltSize, MMO, SB.RS);
17571757
} else {
17581758
unsigned Opc = ST.enableFlatScratch() ? AMDGPU::SCRATCH_STORE_DWORD_SADDR
17591759
: AMDGPU::BUFFER_STORE_DWORD_OFFSET;
17601760
buildSpillLoadStore(*SB.MBB, SB.MI, SB.DL, Opc, Index, SB.TmpVGPR, IsKill,
1761-
FrameReg, Offset * SB.EltSize, MMO, SB.RS);
1761+
FrameReg, (int64_t)Offset * SB.EltSize, MMO, SB.RS);
17621762
// This only ever adds one VGPR spill
17631763
SB.MFI.addToSpilledVGPRs(1);
17641764
}

0 commit comments

Comments
 (0)