summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/Disassembler
diff options
context:
space:
mode:
authorTim Corringham <tcorring@amd.com>2018-03-26 17:06:33 +0000
committerTim Corringham <tcorring@amd.com>2018-03-26 17:06:33 +0000
commit7116e8963df0f3507b86c36953b22d4958b299f1 (patch)
tree00d507be627881c4f6efcdaf189a7d6cd639d7f6 /llvm/lib/Target/AMDGPU/Disassembler
parentfbfba29d74748b8fffd2f7cc654fb4c3659c8f67 (diff)
downloadbcm5719-llvm-7116e8963df0f3507b86c36953b22d4958b299f1.tar.gz
bcm5719-llvm-7116e8963df0f3507b86c36953b22d4958b299f1.zip
[AMDGPU] Improve disassembler error handling
Summary: llvm-objdump now disassembles unrecognised opcodes as data, using the .long directive. We treat unrecognised opcodes as being 32 bit values, so move along 4 bytes rather than the single byte which previously resulted in a cascade of bogus disassembly following an unrecognised opcode. While no solution can always disassemble code that contains embedded data correctly this provides a significant improvement. The disassembler will now cope with an arbitrary length section as it no longer truncates it to a multiple of 4 bytes, and will use the .byte directive for trailing bytes. Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits Differential Revision: https://reviews.llvm.org/D44685 llvm-svn: 328553
Diffstat (limited to 'llvm/lib/Target/AMDGPU/Disassembler')
-rw-r--r--llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
index 75356e9a9d3..9732d11adee 100644
--- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
+++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
@@ -246,7 +246,10 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
if (Res && IsSDWA)
Res = convertSDWAInst(MI);
- Size = Res ? (MaxInstBytesNum - Bytes.size()) : 0;
+ // if the opcode was not recognized we'll assume a Size of 4 bytes
+ // (unless there are fewer bytes left)
+ Size = Res ? (MaxInstBytesNum - Bytes.size())
+ : std::min((size_t)4, Bytes_.size());
return Res;
}
OpenPOWER on IntegriCloud