Index: lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp =================================================================== --- lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp +++ lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp @@ -246,7 +246,8 @@ 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 + Size = Res ? (MaxInstBytesNum - Bytes.size()) : 4; return Res; } Index: test/MC/AMDGPU/data.s =================================================================== --- /dev/null +++ test/MC/AMDGPU/data.s @@ -0,0 +1,22 @@ +// We check that unrecognized opcodes are disassembled by llvm-objdump as data using the .long directive +// RUN: llvm-mc -filetype=obj -triple=amdgcn--amdpal -mcpu=gfx900 -show-encoding %s | llvm-objdump -disassemble -mcpu=gfx900 - | FileCheck %s + +.text + v_mov_b32 v7, s24 + v_mov_b32 v8, s25 + .long 0xabadc0de + s_nop 0 + s_endpgm + .long 0xbadc0de1, 0xbadc0de2, 0xbadc0de3, 0xbadc0de4 + +// CHECK: .text +// CHECK: v_mov_b32 +// CHECK: v_mov_b32 +// CHECK: .long 0xabadc0de +// CHECK_SAME: : ABADC0DE +// CHECK: s_endpgm +// CHECK: .long 0xbadc0de1 +// CHECK: .long 0xbadc0de2 +// CHECK: .long 0xbadc0de3 +// CHECK: .long 0xbadc0de4 +// CHECK-NOT: .long Index: tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- tools/llvm-objdump/llvm-objdump.cpp +++ tools/llvm-objdump/llvm-objdump.cpp @@ -595,18 +595,24 @@ if (SP && (PrintSource || PrintLines)) SP->printSourceLine(OS, Address); - if (!MI) { - OS << " "; - return; - } + typedef support::ulittle32_t U32; - SmallString<40> InstStr; - raw_svector_ostream IS(InstStr); + if (MI) { + SmallString<40> InstStr; + raw_svector_ostream IS(InstStr); - IP.printInst(MI, IS, "", STI); + IP.printInst(MI, IS, "", STI); - OS << left_justify(IS.str(), 60) << format("// %012" PRIX64 ": ", Address); - typedef support::ulittle32_t U32; + OS << left_justify(IS.str(), 60); + } else { + // an unrecognized encoding - this is probably data so represent it + // using the .long directive + OS << format("\t.long 0x%08" PRIx32 " ", + static_cast(*reinterpret_cast(Bytes.data()))); + OS.indent(42); + } + + OS << format("// %012" PRIX64 ": ", Address); for (auto D : makeArrayRef(reinterpret_cast(Bytes.data()), Bytes.size() / sizeof(U32))) // D should be explicitly casted to uint32_t here as it is passed