mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +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…
Reference in New Issue
Block a user