[llvm] a9fe7a5 - [CodeGen] Prevent potential multiplication overflow (#224665)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 06:26:11 PDT 2026
Author: Igor Wodiany
Date: 2026-09-22T14:26:05+01:00
New Revision: a9fe7a5e5fbc96c15f929ffd313215752bd0d36e
URL: https://github.com/llvm/llvm-project/commit/a9fe7a5e5fbc96c15f929ffd313215752bd0d36e
DIFF: https://github.com/llvm/llvm-project/commit/a9fe7a5e5fbc96c15f929ffd313215752bd0d36e.diff
LOG: [CodeGen] Prevent potential multiplication overflow (#224665)
This fixes a number of issues reported by a CodeQL scan in the `CodeGen`
directory.
Added:
Modified:
llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
llvm/lib/CodeGen/ModuloSchedule.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp b/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
index c5f093bf34a91..5cdaedc143c13 100644
--- a/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
+++ b/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
@@ -730,9 +730,9 @@ struct VectorInfo {
///
/// \returns true if this is possible and false if not
bool isInterleaved(unsigned Factor, const DataLayout &DL) const {
- unsigned Size = DL.getTypeAllocSize(VTy->getElementType());
+ TypeSize Size = DL.getTypeAllocSize(VTy->getElementType());
for (unsigned i = 1; i < getDimension(); i++) {
- if (!EI[i].Ofs.isProvenEqualTo(EI[0].Ofs + i * Factor * Size)) {
+ if (!EI[i].Ofs.isProvenEqualTo(EI[0].Ofs + i * Size * Factor)) {
return false;
}
}
@@ -782,8 +782,8 @@ struct VectorInfo {
return false;
unsigned Factor = Result.VTy->getNumElements() / VTy->getNumElements();
- unsigned NewSize = DL.getTypeAllocSize(Result.VTy->getElementType());
- unsigned OldSize = DL.getTypeAllocSize(VTy->getElementType());
+ TypeSize NewSize = DL.getTypeAllocSize(Result.VTy->getElementType());
+ TypeSize OldSize = DL.getTypeAllocSize(VTy->getElementType());
if (NewSize * Factor != OldSize)
return false;
diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp
index dc7d3a6871633..a86ca6ff7e1e8 100644
--- a/llvm/lib/CodeGen/ModuloSchedule.cpp
+++ b/llvm/lib/CodeGen/ModuloSchedule.cpp
@@ -992,7 +992,7 @@ void ModuloScheduleExpander::updateMemOperands(MachineInstr &NewMI,
}
unsigned Delta;
if (Num != UINT_MAX && computeDelta(OldMI, Delta)) {
- int64_t AdjOffset = Delta * Num;
+ int64_t AdjOffset = static_cast<int64_t>(Delta) * Num;
NewMMOs.push_back(
MF.getMachineMemOperand(MMO, AdjOffset, MMO->getSize()));
} else {
More information about the llvm-commits
mailing list