[PATCH] D54420: Fix .cfi_restore with register numbers > 64

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 13 02:57:31 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL346751: Fix .cfi_restore with register numbers > 64 (authored by arichardson, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D54420

Files:
  llvm/trunk/lib/MC/MCDwarf.cpp
  llvm/trunk/test/MC/ELF/cfi-restore-extended.s


Index: llvm/trunk/lib/MC/MCDwarf.cpp
===================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp
+++ llvm/trunk/lib/MC/MCDwarf.cpp
@@ -1418,7 +1418,12 @@
     unsigned Reg = Instr.getRegister();
     if (!IsEH)
       Reg = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);
-    Streamer.EmitIntValue(dwarf::DW_CFA_restore | Reg, 1);
+    if (Reg < 64) {
+      Streamer.EmitIntValue(dwarf::DW_CFA_restore | Reg, 1);
+    } else {
+      Streamer.EmitIntValue(dwarf::DW_CFA_restore_extended, 1);
+      Streamer.EmitULEB128IntValue(Reg);
+    }
     return;
   }
   case MCCFIInstruction::OpGnuArgsSize:
Index: llvm/trunk/test/MC/ELF/cfi-restore-extended.s
===================================================================
--- llvm/trunk/test/MC/ELF/cfi-restore-extended.s
+++ llvm/trunk/test/MC/ELF/cfi-restore-extended.s
@@ -0,0 +1,17 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-dwarfdump -debug-frame - | FileCheck %s
+
+// Check that register numbers greater than 63 can be used in .cfi_restore directives
+f:
+  .cfi_startproc
+  nop
+// CHECK: DW_CFA_advance_loc: 1
+  .cfi_restore %rbp
+// CHECK-NEXT: DW_CFA_restore: reg6
+  nop
+// CHECK-NEXT: DW_CFA_advance_loc: 1
+  .cfi_restore 89
+// CHECK-NEXT: DW_CFA_restore_extended: reg89
+// CHECK-NEXT: DW_CFA_nop:
+  nop
+  .cfi_endproc
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54420.173827.patch
Type: text/x-patch
Size: 1364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181113/c13400d0/attachment.bin>


More information about the llvm-commits mailing list