forked from OSchip/llvm-project
[NFC] Assert non-zero factor before division
This is to ensure that zero denominator leads to controlled assertion failure rather than UB.
This commit is contained in:
parent
6f665cd53d
commit
fa5eb22ad4
|
@ -3919,6 +3919,7 @@ void LSRInstance::GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx,
|
||||||
if (Base.BaseOffset == std::numeric_limits<int64_t>::min() && Factor == -1)
|
if (Base.BaseOffset == std::numeric_limits<int64_t>::min() && Factor == -1)
|
||||||
continue;
|
continue;
|
||||||
int64_t NewBaseOffset = (uint64_t)Base.BaseOffset * Factor;
|
int64_t NewBaseOffset = (uint64_t)Base.BaseOffset * Factor;
|
||||||
|
assert(Factor != 0 && "Zero factor not expected!");
|
||||||
if (NewBaseOffset / Factor != Base.BaseOffset)
|
if (NewBaseOffset / Factor != Base.BaseOffset)
|
||||||
continue;
|
continue;
|
||||||
// If the offset will be truncated at this use, check that it is in bounds.
|
// If the offset will be truncated at this use, check that it is in bounds.
|
||||||
|
|
Loading…
Reference in New Issue