diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp index 2d7c25f31d8..4581f411304 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/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/test/MC/ARM/dwarf-cfi-initial-state.s b/test/MC/ARM/dwarf-cfi-initial-state.s new file mode 100644 index 00000000000..2d638e9c4b2 --- /dev/null +++ b/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