AMDGPU/MC: Allow disassembling without symbol info
authorNicolai Haehnle <nhaehnle@gmail.com>
Tue, 10 Apr 2018 15:46:43 +0000 (15:46 +0000)
committerNicolai Haehnle <nhaehnle@gmail.com>
Tue, 10 Apr 2018 15:46:43 +0000 (15:46 +0000)
Summary:
We would like the UMR debugging tool[0] to be able to provide
disassembly for currently live waves based on plain memory
dumps, and we want to leverage the LLVM disassembler for this.

This mostly works, except that UMR clearly can't provide real
symbol info, so it wants to set DisInfo == nullptr.

[0] https://cgit.freedesktop.org/amd/umr/

Reviewers: arsenm, rampitec, artem.tamazov, dp

Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits

Differential Revision: https://reviews.llvm.org/D45477

Change-Id: Ibb2c5af2e66f2e100b4702fd81308e1932bc4ee6
llvm-svn: 329715

llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp

index 9732d11..b51c23f 100644 (file)
@@ -882,6 +882,9 @@ bool AMDGPUSymbolizer::tryAddingSymbolicOperand(MCInst &Inst,
   }
 
   auto *Symbols = static_cast<SectionSymbolsTy *>(DisInfo);
+  if (!Symbols)
+    return false;
+
   auto Result = std::find_if(Symbols->begin(), Symbols->end(),
                              [Value](const SymbolInfoTy& Val) {
                                 return std::get<0>(Val) == static_cast<uint64_t>(Value)