forked from OSchip/llvm-project
Fix undefined behavior (left shift of negative value) in Hexagon backend.
This bug is reported by UBSan. llvm-svn: 216125
This commit is contained in:
parent
ea0aee622e
commit
2651ae6513
|
@ -1766,7 +1766,7 @@ int HexagonInstrInfo::getMinValue(const MachineInstr *MI) const {
|
|||
& HexagonII::ExtentBitsMask;
|
||||
|
||||
if (isSigned) // if value is signed
|
||||
return -1 << (bits - 1);
|
||||
return -1U << (bits - 1);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -1780,9 +1780,9 @@ int HexagonInstrInfo::getMaxValue(const MachineInstr *MI) const {
|
|||
& HexagonII::ExtentBitsMask;
|
||||
|
||||
if (isSigned) // if value is signed
|
||||
return ~(-1 << (bits - 1));
|
||||
return ~(-1U << (bits - 1));
|
||||
else
|
||||
return ~(-1 << bits);
|
||||
return ~(-1U << bits);
|
||||
}
|
||||
|
||||
// Returns true if an instruction can be converted into a non-extended
|
||||
|
|
|
@ -155,7 +155,7 @@ int HexagonMCInst::getMinValue(void) const {
|
|||
& HexagonII::ExtentBitsMask;
|
||||
|
||||
if (isSigned) // if value is signed
|
||||
return -1 << (bits - 1);
|
||||
return -1U << (bits - 1);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ int HexagonMCInst::getMaxValue(void) const {
|
|||
& HexagonII::ExtentBitsMask;
|
||||
|
||||
if (isSigned) // if value is signed
|
||||
return ~(-1 << (bits - 1));
|
||||
return ~(-1U << (bits - 1));
|
||||
else
|
||||
return ~(-1 << bits);
|
||||
return ~(-1U << bits);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue