[PATCH] D147980: Emit unwind information in .debug_frame section when .cfi_sections .debug_frame intrinsic is used
Shubham Sandeep Rastogi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 17:13:12 PDT 2023
rastogishubham created this revision.
rastogishubham added reviewers: aprantl, friss, t.p.northover.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
rastogishubham requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The
.cfi_sections .debug_frame
intrinsic is used to emit .debug_frame section. This directive tells the assembler to write out a section of debug frame data. ARM64 however, is a platform where eh_frame is not needed for unwind information. Unfortunately, that means that even when the
.cfi_sections .debug_frame
intrinsic is used, the compiler skips emitting the CIE's and FDE's in the debug_frame section. This patch address that issue by making sure that the emission of CIE's and FDE's are only skipped if the unwind information does not require a debug_frame section and is a platform where the eh_frame can be skipped
https://reviews.llvm.org/D147980
Files:
llvm/lib/MC/MCDwarf.cpp
llvm/test/DebugInfo/AArch64/debugframeinfo.s
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:
Index: llvm/lib/MC/MCDwarf.cpp
===================================================================
--- llvm/lib/MC/MCDwarf.cpp
+++ llvm/lib/MC/MCDwarf.cpp
@@ -1856,7 +1856,6 @@
const MCAsmInfo *AsmInfo = Context.getAsmInfo();
FrameEmitterImpl Emitter(IsEH, Streamer);
ArrayRef<MCDwarfFrameInfo> FrameArray = Streamer.getDwarfFrameInfos();
-
// Emit the compact unwind info if available.
bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame();
if (IsEH && MOFI->getCompactUnwindSection()) {
@@ -1876,7 +1875,7 @@
}
}
- if (!NeedsEHFrameSection) return;
+ if (!NeedsEHFrameSection && IsEH) return;
MCSection &Section =
IsEH ? *const_cast<MCObjectFileInfo *>(MOFI)->getEHFrameSection()
@@ -1903,7 +1902,7 @@
const MCDwarfFrameInfo &Frame = *I;
++I;
if (CanOmitDwarf && Frame.CompactUnwindEncoding !=
- MOFI->getCompactUnwindDwarfEHFrameOnly())
+ MOFI->getCompactUnwindDwarfEHFrameOnly() && IsEH)
// Don't generate an EH frame if we don't need one. I.e., it's taken care
// of by the compact unwind encoding.
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147980.512289.patch
Type: text/x-patch
Size: 2582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230411/901f19ac/attachment.bin>
More information about the llvm-commits
mailing list