aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2014-01-27 22:38:14 +0000
committerMark Seaborn <mseaborn@chromium.org>2014-01-27 22:38:14 +0000
commitba86cf51c96e27ab404c4406f13f617b33a4ed6c (patch)
tree9f6921e49900a8e8181f0644f88004f78e136f2a
parent122d94fd613efdd2fff30b13ebdd6e187780537d (diff)
downloadllvm-ba86cf51c96e27ab404c4406f13f617b33a4ed6c.zip
llvm-ba86cf51c96e27ab404c4406f13f617b33a4ed6c.tar.gz
llvm-ba86cf51c96e27ab404c4406f13f617b33a4ed6c.tar.bz2
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 will tend to cause GDB to abort with: gdb/dwarf2-frame.c:1132: internal-error: Unknown CFA rule. I've also tested this by comparing the output of "readelf -w" on the object files produced by llvm-mc and gas when given the .s file added here. This change is part of addressing PR18636. Differential Revision: http://llvm-reviews.chandlerc.com/D2597 llvm-svn: 200255
-rw-r--r--llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp10
-rw-r--r--llvm/test/MC/ARM/dwarf-cfi-initial-state.s16
2 files changed, 24 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
index 2d7c25f..4581f41 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
@@ -212,10 +212,16 @@ static MCRegisterInfo *createARMMCRegisterInfo(StringRef Triple) {
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,
diff --git a/llvm/test/MC/ARM/dwarf-cfi-initial-state.s b/llvm/test/MC/ARM/dwarf-cfi-initial-state.s
new file mode 100644
index 0000000..2d638e9
--- /dev/null
+++ b/llvm/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