Index: llvm/lib/MC/MCDwarf.cpp =================================================================== --- llvm/lib/MC/MCDwarf.cpp +++ llvm/lib/MC/MCDwarf.cpp @@ -1876,7 +1876,11 @@ } } - if (!NeedsEHFrameSection) return; + // Compact unwind information can be emitted in the eh_frame section or the + // debug_frame section. Skip emitting FDEs and CIEs when the compact unwind + // doesn't need an eh_frame section and the emission location is the eh_frame + // section. + if (!NeedsEHFrameSection && IsEH) return; MCSection &Section = IsEH ? *const_cast(MOFI)->getEHFrameSection() @@ -1903,9 +1907,10 @@ const MCDwarfFrameInfo &Frame = *I; ++I; if (CanOmitDwarf && Frame.CompactUnwindEncoding != - MOFI->getCompactUnwindDwarfEHFrameOnly()) - // Don't generate an EH frame if we don't need one. I.e., it's taken care - // of by the compact unwind encoding. + MOFI->getCompactUnwindDwarfEHFrameOnly() && IsEH) + // Don't generate an EH frame if we don't need one and location of unwind + // information is the eh_frame section. I.e., it's taken care of by the + // compact unwind encoding. continue; CIEKey Key(Frame); Index: llvm/test/DebugInfo/AArch64/debugframeinfo.s =================================================================== --- /dev/null +++ llvm/test/DebugInfo/AArch64/debugframeinfo.s @@ -0,0 +1,43 @@ +# RUN: llvm-mc -filetype=obj --triple=arm64-apple-darwin22.1.0 %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 00000014 00000000 FDE cie=00000000 pc=00000000...00000000 +# CHECK-NEXT: Format: DWARF32 +# CHECK-EMPTY: +# CHECK-NEXT: 0x0: CFA=WSP + +# CHECK: .eh_frame contents: +# CHECK-EMPTY: +# CHECK-EMPTY: + + .cfi_sections .debug_frame + .cfi_startproc + .cfi_personality 0x9b, g + .cfi_lsda 0x1b, h + .cfi_endproc + .global g +g: + .global h +h: