From d96ade00c3c96bd451c60e34a17e613cdd5fdc38 Mon Sep 17 00:00:00 2001 From: Shubham Sandeep Rastogi Date: Thu, 6 Oct 2022 12:15:07 -0700 Subject: Remove the dependency between lib/DebugInfoDWARF and MC. This patch had to be reverted because on gcc 7.5.0 we see an error converting from std::unique_ptr to Expected> as the return type for the function createRegInfo. This has now been fixed. --- llvm/tools/llvm-objdump/SourcePrinter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'llvm/tools/llvm-objdump/SourcePrinter.cpp') diff --git a/llvm/tools/llvm-objdump/SourcePrinter.cpp b/llvm/tools/llvm-objdump/SourcePrinter.cpp index c8ea6b5..67ced1c 100644 --- a/llvm/tools/llvm-objdump/SourcePrinter.cpp +++ b/llvm/tools/llvm-objdump/SourcePrinter.cpp @@ -42,7 +42,16 @@ void LiveVariable::print(raw_ostream &OS, const MCRegisterInfo &MRI) const { DataExtractor Data({LocExpr.Expr.data(), LocExpr.Expr.size()}, Unit->getContext().isLittleEndian(), 0); DWARFExpression Expression(Data, Unit->getAddressByteSize()); - Expression.printCompact(OS, MRI); + + auto GetRegName = [&MRI, &OS](uint64_t DwarfRegNum, bool IsEH) -> StringRef { + if (Optional LLVMRegNum = MRI.getLLVMRegNum(DwarfRegNum, IsEH)) + if (const char *RegName = MRI.getName(*LLVMRegNum)) + return StringRef(RegName); + OS << ""; + return {}; + }; + + Expression.printCompact(OS, GetRegName); } void LiveVariablePrinter::addVariable(DWARFDie FuncDie, DWARFDie VarDie) { -- cgit v1.1