[llvm] 710290c - Emit unwind information in .debug_frame section when .cfi_sections .debug_frame intrinsic is used
Shubham Sandeep Rastogi via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 26 16:20:16 PDT 2023
Author: Shubham Sandeep Rastogi
Date: 2023-04-26T16:19:53-07:00
New Revision: 710290cecce74da1368675ff3686a25037045246
URL: https://github.com/llvm/llvm-project/commit/710290cecce74da1368675ff3686a25037045246
DIFF: https://github.com/llvm/llvm-project/commit/710290cecce74da1368675ff3686a25037045246.diff
LOG: Emit unwind information in .debug_frame section when .cfi_sections .debug_frame intrinsic is used
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. AArch64 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.
Differential Revision: https://reviews.llvm.org/D147980
Added:
llvm/test/DebugInfo/AArch64/debugframeinfo.s
Modified:
llvm/lib/MC/MCDwarf.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 30b8aadbf63c3..66984ce08ad52 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -1876,7 +1876,11 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
}
}
- 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<MCObjectFileInfo *>(MOFI)->getEHFrameSection()
@@ -1903,9 +1907,13 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
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)
+ // CIEs and FDEs can be emitted in either the eh_frame section or the
+ // debug_frame section, on some platforms (e.g. AArch64) the target object
+ // file supports emitting a compact_unwind section without an associated
+ // eh_frame section. If the eh_frame section is not needed, and the
+ // location where the CIEs and FDEs are to be emitted is the eh_frame
+ // section, do not emit anything.
continue;
CIEKey Key(Frame);
diff --git a/llvm/test/DebugInfo/AArch64/debugframeinfo.s b/llvm/test/DebugInfo/AArch64/debugframeinfo.s
new file mode 100644
index 0000000000000..5159c07489e33
--- /dev/null
+++ b/llvm/test/DebugInfo/AArch64/debugframeinfo.s
@@ -0,0 +1,20 @@
+# 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: {{.+}}
+
+# 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:
More information about the llvm-commits
mailing list