Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion llvm/lib/MC/MCAsmStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ class MCAsmStreamer final : public MCStreamer {
void emitGNUAttribute(unsigned Tag, unsigned Value) override;

StringRef getMnemonic(MCInst &MI) override {
return InstPrinter->getMnemonic(&MI).first;
auto [Ptr, Bits] = InstPrinter->getMnemonic(&MI);
assert((Bits != 0 || Ptr == nullptr) &&
"Invalid char pointer for instruction with no mnemonic");
return Ptr;
}

void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
Expand Down
4 changes: 4 additions & 0 deletions llvm/utils/TableGen/AsmWriterEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ void AsmWriterEmitter::EmitGetMnemonic(
O << " // Emit the opcode for the instruction.\n";
O << BitsString;

// Make sure we don't return an invalid pointer if bits is 0
O << " if (Bits == 0)\n"
" return {nullptr, Bits};\n";

// Return mnemonic string and bits.
O << " return {AsmStrs+(Bits & " << (1 << AsmStrBits) - 1
<< ")-1, Bits};\n\n";
Expand Down