aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2010-04-19 23:02:58 +0000
committerJohnny Chen <johnny.chen@apple.com>2010-04-19 23:02:58 +0000
commitd0f3c46d166b5d0ab4573987011cab7bd1ec28e0 (patch)
tree7100e8bfad9b253f858ed200b554b9243f85be46 /lib/Target/ARM/Disassembler/ARMDisassembler.cpp
parent35bb85b7ee108a265a20686e97d1b011f4ab5ce9 (diff)
Better error handling of invalid IT mask '0000', instead of just asserting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/Disassembler/ARMDisassembler.cpp')
-rw-r--r--lib/Target/ARM/Disassembler/ARMDisassembler.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Target/ARM/Disassembler/ARMDisassembler.cpp b/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
index 0e27e16f94..1c9d95fb08 100644
--- a/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
+++ b/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
@@ -508,17 +508,23 @@ bool ThumbDisassembler::getInstruction(MCInst &MI,
}
// A8.6.50
+// Valid return values are {1, 2, 3, 4}, with 0 signifying an error condition.
static unsigned short CountITSize(unsigned ITMask) {
// First count the trailing zeros of the IT mask.
unsigned TZ = CountTrailingZeros_32(ITMask);
- assert(TZ <= 3 && "Encoding error");
+ if (TZ > 3) {
+ DEBUG(errs() << "Encoding error of IT mask");
+ return 0;
+ }
return (4 - TZ);
}
-/// Init ITState.
-void Session::InitIT(unsigned short bits7_0) {
+/// Init ITState. Note that at least one bit is always 1 in mask.
+bool Session::InitIT(unsigned short bits7_0) {
ITCounter = CountITSize(slice(bits7_0, 3, 0));
ITState = bits7_0;
+ // Only need to check for > 0.
+ return ITCounter > 0;
}
/// Update ITState if necessary.