[PATCH] ARM MC: Fix the initial DWARF CFI unwind info at the start of a function
Mark Seaborn
mseaborn at chromium.org
Wed Jan 22 14:56:14 PST 2014
Hi rafael, dschuff, jvoung,
ARM MC: Fix the initial DWARF CFI unwind info at the start of a function
This brings MC into line with GNU 'as' on ARM, and it brings the ARM
target into line with most other LLVM targets, which declare the
initial CFI state with addInitialFrameState().
Without this, functions generated with .cfi_startproc/endproc on ARM
tend to cause GDB to abort with:
gdb/dwarf2-frame.c:1132: internal-error: Unknown CFA rule.
http://llvm-reviews.chandlerc.com/D2597
Files:
lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
test/MC/ARM/dwarf-cfi-initial-state.s
Index: lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
===================================================================
--- lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
+++ lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
@@ -212,10 +212,16 @@
static MCAsmInfo *createARMMCAsmInfo(const MCRegisterInfo &MRI, StringRef TT) {
Triple TheTriple(TT);
+ MCAsmInfo *MAI;
if (TheTriple.isOSBinFormatMachO())
- return new ARMMCAsmInfoDarwin();
+ MAI = new ARMMCAsmInfoDarwin();
+ else
+ MAI = new ARMELFMCAsmInfo();
- return new ARMELFMCAsmInfo();
+ unsigned Reg = MRI.getDwarfRegNum(ARM::SP, true);
+ MAI->addInitialFrameState(MCCFIInstruction::createDefCfa(0, Reg, 0));
+
+ return MAI;
}
static MCCodeGenInfo *createARMMCCodeGenInfo(StringRef TT, Reloc::Model RM,
Index: test/MC/ARM/dwarf-cfi-initial-state.s
===================================================================
--- /dev/null
+++ test/MC/ARM/dwarf-cfi-initial-state.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o - \
+# RUN: | llvm-dwarfdump - | FileCheck %s
+
+.cfi_sections .debug_frame
+.cfi_startproc
+bx lr
+.cfi_endproc
+
+# CHECK: .debug_frame contents:
+# CHECK: CIE
+# CHECK-NOT: DW_CFA
+# When llvm-dwarfdump prints the full info for the DW_CFA_def_cfa
+# field, we can check that here too.
+# CHECK: DW_CFA_def_cfa:
+# CHECK-NOT: DW_CFA
+# CHECK: FDE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2597.1.patch
Type: text/x-patch
Size: 1397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140122/9645cfdf/attachment.bin>
More information about the llvm-commits
mailing list