Skip to content

Commit b40ef2c

Browse files
authored
[RISCV][Disassemble] Ensure the comment stream of the disassembler is set. (#125962)
1 parent f729477 commit b40ef2c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

llvm/lib/MC/MCDisassembler/MCDisassembler.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,21 @@ bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
2929
uint64_t Address, bool IsBranch,
3030
uint64_t Offset, uint64_t OpSize,
3131
uint64_t InstSize) const {
32-
if (Symbolizer)
32+
if (Symbolizer) {
33+
assert(CommentStream && "CommentStream is not set.");
3334
return Symbolizer->tryAddingSymbolicOperand(Inst, *CommentStream, Value,
3435
Address, IsBranch, Offset,
3536
OpSize, InstSize);
37+
}
3638
return false;
3739
}
3840

3941
void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
4042
uint64_t Address) const {
41-
if (Symbolizer)
43+
if (Symbolizer) {
44+
assert(CommentStream && "CommentStream is not set.");
4245
Symbolizer->tryAddingPcLoadReferenceComment(*CommentStream, Value, Address);
46+
}
4347
}
4448

4549
void MCDisassembler::setSymbolizer(std::unique_ptr<MCSymbolizer> Symzer) {

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
789789
ArrayRef<uint8_t> Bytes,
790790
uint64_t Address,
791791
raw_ostream &CS) const {
792+
CommentStream = &CS;
792793
// It's a 16 bit instruction if bit 0 and 1 are not 0b11.
793794
if ((Bytes[0] & 0b11) != 0b11)
794795
return getInstruction16(MI, Size, Bytes, Address, CS);

0 commit comments

Comments
 (0)