summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-08-20 21:22:03 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-08-20 21:22:03 +0000
commit2651ae651343bb6d0f030b7b641819e08fbc65a9 (patch)
tree65edeb3899754833b9e750cf72bd912d6e7bce8b /llvm/lib
parentea0aee622e802bae9bc3f74f5109ee42245bd7e5 (diff)
downloadbcm5719-llvm-2651ae651343bb6d0f030b7b641819e08fbc65a9.tar.gz
bcm5719-llvm-2651ae651343bb6d0f030b7b641819e08fbc65a9.zip
Fix undefined behavior (left shift of negative value) in Hexagon backend.
This bug is reported by UBSan. llvm-svn: 216125
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp6
-rw-r--r--llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp6
2 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
index 41de8489ed8..a63e3826f07 100644
--- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
@@ -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
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp
index 98b8db07638..c842b9b7cf3 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp
@@ -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);
}
OpenPOWER on IntegriCloud