diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -12,6 +12,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/MC/MCRegisterInfo.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DataExtractor.h" @@ -29,6 +30,18 @@ using namespace llvm; using namespace dwarf; +static void printRegister(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, + unsigned RegNum) { + if (MRI) { + if (Optional LLVMRegNum = MRI->getLLVMRegNum(RegNum, IsEH)) { + if (const char *RegName = MRI->getName(*LLVMRegNum)) { + OS << RegName; + return; + } + } + } + OS << "reg" << RegNum; +} // See DWARF standard v3, section 7.23 const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0; @@ -268,7 +281,8 @@ OS << format(" %" PRId64 "*data_alignment_factor" , Operand); break; case OT_Register: - OS << format(" reg%" PRId64, Operand); + OS << ' '; + printRegister(OS, MRI, IsEH, Operand); break; case OT_Expression: assert(Instr.Expression && "missing DWARFExpression object"); diff --git a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp --- a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp +++ b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp @@ -66,7 +66,8 @@ uint32_t DWARFToGSYMFileIndex(GsymCreator &Gsym, uint32_t DwarfFileIdx) { if (!LineTable) return 0; - assert(DwarfFileIdx < FileCache.size()); + if (DwarfFileIdx >= FileCache.size()) + return 0; uint32_t &GsymFileIdx = FileCache[DwarfFileIdx]; if (GsymFileIdx != UINT32_MAX) return GsymFileIdx; diff --git a/llvm/test/DebugInfo/dwarfdump-debug-frame-simple.test b/llvm/test/DebugInfo/dwarfdump-debug-frame-simple.test --- a/llvm/test/DebugInfo/dwarfdump-debug-frame-simple.test +++ b/llvm/test/DebugInfo/dwarfdump-debug-frame-simple.test @@ -5,8 +5,8 @@ ; FRAMES: 00000000 00000010 ffffffff CIE ; FRAMES: Version: 1 -; FRAMES: DW_CFA_def_cfa: reg4 +4 -; FRAMES-NEXT: DW_CFA_offset: reg8 -4 +; FRAMES: DW_CFA_def_cfa: ESP +4 +; FRAMES-NEXT: DW_CFA_offset: EIP -4 ; FRAMES-NEXT: DW_CFA_nop: ; FRAMES-NEXT: DW_CFA_nop: @@ -18,9 +18,9 @@ ; FRAMES: 00000028 00000014 00000000 FDE cie=00000000 pc=00000030...00000080 ; FRAMES: DW_CFA_advance_loc: 1 ; FRAMES-NEXT: DW_CFA_def_cfa_offset: +8 -; FRAMES-NEXT: DW_CFA_offset: reg5 -8 +; FRAMES-NEXT: DW_CFA_offset: EBP -8 ; FRAMES-NEXT: DW_CFA_advance_loc: 2 -; FRAMES-NEXT: DW_CFA_def_cfa_register: reg5 +; FRAMES-NEXT: DW_CFA_def_cfa_register: EBP ; FRAMES-NOT: CIE ; FRAMES-NOT: FDE diff --git a/llvm/test/MC/ELF/cfi-restore-extended.s b/llvm/test/MC/ELF/cfi-restore-extended.s --- a/llvm/test/MC/ELF/cfi-restore-extended.s +++ b/llvm/test/MC/ELF/cfi-restore-extended.s @@ -6,7 +6,7 @@ nop // CHECK: DW_CFA_advance_loc: 1 .cfi_restore %rbp -// CHECK-NEXT: DW_CFA_restore: reg6 +// CHECK-NEXT: DW_CFA_restore: RBP nop // CHECK-NEXT: DW_CFA_advance_loc: 1 .cfi_restore 89 @@ -14,4 +14,3 @@ // CHECK-NEXT: DW_CFA_nop: nop .cfi_endproc - diff --git a/llvm/test/MC/X86/i386-darwin-frame-register.ll b/llvm/test/MC/X86/i386-darwin-frame-register.ll --- a/llvm/test/MC/X86/i386-darwin-frame-register.ll +++ b/llvm/test/MC/X86/i386-darwin-frame-register.ll @@ -11,7 +11,7 @@ ; CHECK: .debug_frame contents: ; CHECK: ffffffff CIE ; CHECK-NOT: {{CIE|FDE}} -; CHECK: DW_CFA_def_cfa: reg4 +4 +; CHECK: DW_CFA_def_cfa: ESP +4 ; ModuleID = 'foo.c' target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"