Index: llvm/include/llvm/MC/MCDwarf.h =================================================================== --- llvm/include/llvm/MC/MCDwarf.h +++ llvm/include/llvm/MC/MCDwarf.h @@ -703,7 +703,8 @@ // // This emits the frame info section. // - static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH); + static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool IsEH, + bool IsDebugFrame); static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta); static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, raw_ostream &OS); Index: llvm/lib/MC/MCDwarf.cpp =================================================================== --- llvm/lib/MC/MCDwarf.cpp +++ llvm/lib/MC/MCDwarf.cpp @@ -1851,7 +1851,7 @@ } // end namespace llvm void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB, - bool IsEH) { + bool IsEH, bool IsDebugFrame) { MCContext &Context = Streamer.getContext(); const MCObjectFileInfo *MOFI = Context.getObjectFileInfo(); const MCAsmInfo *AsmInfo = Context.getAsmInfo(); @@ -1860,7 +1860,7 @@ // Emit the compact unwind info if available. bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame(); - if (IsEH && MOFI->getCompactUnwindSection()) { + if ((IsEH || IsDebugFrame) && MOFI->getCompactUnwindSection()) { Streamer.generateCompactUnwindEncodings(MAB); bool SectionEmitted = false; for (const MCDwarfFrameInfo &Frame : FrameArray) { Index: llvm/lib/MC/MCObjectStreamer.cpp =================================================================== --- llvm/lib/MC/MCObjectStreamer.cpp +++ llvm/lib/MC/MCObjectStreamer.cpp @@ -192,10 +192,10 @@ return; if (EmitEHFrame) - MCDwarfFrameEmitter::Emit(*this, MAB, true); + MCDwarfFrameEmitter::Emit(*this, MAB, true, false); if (EmitDebugFrame) - MCDwarfFrameEmitter::Emit(*this, MAB, false); + MCDwarfFrameEmitter::Emit(*this, MAB, false, true); } MCFragment *MCObjectStreamer::getCurrentFragment() const { Index: llvm/test/DebugInfo/debugframeinfo.s =================================================================== --- /dev/null +++ llvm/test/DebugInfo/debugframeinfo.s @@ -0,0 +1,44 @@ +# RUN: llvm-mc -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump -debug-frame %t.o | FileCheck %s + +# CHECK: .debug_frame contents: +# CHECK-EMPTY: +# CHECK-NEXT: 00000000 00000014 ffffffff CIE +# CHECK-NEXT: Format: DWARF32 +# CHECK-NEXT: Version: 4 +# CHECK-NEXT: Augmentation: "" +# CHECK-NEXT: Address size: 8 +# CHECK-NEXT: Segment desc size: 0 +# CHECK-NEXT: Code alignment factor: 1 +# CHECK-NEXT: Data alignment factor: -8 +# CHECK-NEXT: Return address column: 30 +# CHECK-EMPTY: +# CHECK-NEXT: DW_CFA_def_cfa: WSP +0 +# CHECK-NEXT: DW_CFA_nop: +# CHECK-NEXT: DW_CFA_nop: +# CHECK-NEXT: DW_CFA_nop: +# CHECK-NEXT: DW_CFA_nop: +# CHECK-NEXT: DW_CFA_nop: +# CHECK-NEXT: DW_CFA_nop: +# CHECK-EMPTY: +# CHECK-NEXT: CFA=WSP +# CHECK-EMPTY: +# CHECK-NEXT: 00000018 0000001c 00000000 FDE cie=00000000 pc=00000000...00000000 +# CHECK-NEXT: Format: DWARF32 +# CHECK-NEXT: DW_CFA_def_cfa: W28 +832 +# CHECK-NEXT: DW_CFA_nop: +# CHECK-NEXT: DW_CFA_nop: +# CHECK-NEXT: DW_CFA_nop: +# CHECK-NEXT: DW_CFA_nop: +# CHECK-EMPTY: +# CHECK-NEXT: 0x0: CFA=W28+832 +# CHECK-EMPTY: +# CHECK-EMPTY: +# CHECK-NEXT: .eh_frame contents: +# CHECK-EMPTY: + + .cfi_startproc + .cfi_signal_frame + .cfi_def_cfa x28, 0x340 + .cfi_endproc + .cfi_sections .debug_frame