aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCDwarf.cpp
diff options
context:
space:
mode:
authorShubham Sandeep Rastogi <srastogi22@apple.com>2023-04-05 09:05:06 -0700
committerShubham Sandeep Rastogi <srastogi22@apple.com>2023-04-26 16:19:53 -0700
commit710290cecce74da1368675ff3686a25037045246 (patch)
treeb19304146f3deb89f78f0974046ede4eef4fd44e /llvm/lib/MC/MCDwarf.cpp
parentfe8eab468eee18329922901bcf74310534e08b59 (diff)
downloadllvm-710290cecce74da1368675ff3686a25037045246.zip
llvm-710290cecce74da1368675ff3686a25037045246.tar.gz
llvm-710290cecce74da1368675ff3686a25037045246.tar.bz2
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
Diffstat (limited to 'llvm/lib/MC/MCDwarf.cpp')
-rw-r--r--llvm/lib/MC/MCDwarf.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 30b8aad..66984ce 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);