mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-24 11:36:10 +00:00
Fix undefined behavior (left shift of negative value) in Hexagon backend.
This bug is reported by UBSan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216125 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a046b4149c
commit
145d28e73b
@ -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…
x
Reference in New Issue
Block a user