aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
diff options
context:
space:
mode:
authorIvan Kosarev <ivan.kosarev@amd.com>2023-04-26 12:21:50 +0100
committerIvan Kosarev <ivan.kosarev@amd.com>2023-04-26 12:50:17 +0100
commite23891a3823e6bff11a68c08b75d2d45d11832cf (patch)
treef4d82dc966945f62da29840ad7c38a6362486cfe /llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
parentc08dc8b5fbd0e44d5cac7738ffee724d91a26243 (diff)
downloadllvm-e23891a3823e6bff11a68c08b75d2d45d11832cf.zip
llvm-e23891a3823e6bff11a68c08b75d2d45d11832cf.tar.gz
llvm-e23891a3823e6bff11a68c08b75d2d45d11832cf.tar.bz2
[AMDGPU][Disassembler] Fix a spurious error message in an instruction comment.
The patch prevents pollution of instruction comments with error messages generated during unsuccessful decoding attempts. Reviewed By: foad Differential Revision: https://reviews.llvm.org/D149049
Diffstat (limited to 'llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h')
-rw-r--r--llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
index 5b9a155..490eb14 100644
--- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
+++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
@@ -115,14 +115,25 @@ public:
template <typename InsnType>
DecodeStatus tryDecodeInst(const uint8_t *Table, MCInst &MI, InsnType Inst,
- uint64_t Address) const {
+ uint64_t Address, raw_ostream &Comments) const {
assert(MI.getOpcode() == 0);
assert(MI.getNumOperands() == 0);
MCInst TmpInst;
HasLiteral = false;
const auto SavedBytes = Bytes;
- if (decodeInstruction(Table, TmpInst, Inst, Address, this, STI)) {
+
+ SmallString<64> LocalComments;
+ raw_svector_ostream LocalCommentStream(LocalComments);
+ CommentStream = &LocalCommentStream;
+
+ DecodeStatus Res =
+ decodeInstruction(Table, TmpInst, Inst, Address, this, STI);
+
+ CommentStream = nullptr;
+
+ if (Res != Fail) {
MI = TmpInst;
+ Comments << LocalComments;
return MCDisassembler::Success;
}
Bytes = SavedBytes;