https://github.com/vchigrin updated 
https://github.com/llvm/llvm-project/pull/167849

>From 0e4eb0f9772d4f272b5e217f768209991c7e21bd Mon Sep 17 00:00:00 2001
From: Vyacheslav Chigrin <[email protected]>
Date: Thu, 13 Nov 2025 11:49:41 +0300
Subject: [PATCH 1/2] [libunwind] Faster handling of frames with missed FDE
 records.

---
 libunwind/src/UnwindCursor.hpp | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index d7348254af07b..42c3cf9084219 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1787,9 +1787,26 @@ bool UnwindCursor<A, R>::getInfoFromDwarfSection(
   }
   if (!foundFDE) {
     // Still not found, do full scan of __eh_frame section.
-    foundFDE = CFI_Parser<A>::findFDE(_addressSpace, pc, sects.dwarf_section,
-                                      sects.dwarf_section_length, 0,
-                                      &fdeInfo, &cieInfo);
+    // But only if __eh_frame_hdr is absent or empty.
+    // We assume that both sections have the same data, and don't want to waste
+    // time for long scan for absent addresses.
+    bool hasEHHeaderData = false;
+#if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
+    if ((sects.dwarf_index_section != 0)) {
+      typename EHHeaderParser<A>::EHHeaderInfo hdrInfo;
+      const pint_t ehHdrStart = sects.dwarf_index_section;
+      const pint_t ehHdrEnd = ehHdrStart + sects.dwarf_index_section_length;
+      if (EHHeaderParser<A>::decodeEHHdr(_addressSpace, ehHdrStart, ehHdrEnd,
+                                         hdrInfo)) {
+        hasEHHeaderData = (hdrInfo.fde_count != 0);
+      }
+    }
+#endif
+    if (!hasEHHeaderData) {
+      foundFDE = CFI_Parser<A>::findFDE(_addressSpace, pc, sects.dwarf_section,
+                                        sects.dwarf_section_length, 0, 
&fdeInfo,
+                                        &cieInfo);
+    }
   }
   if (foundFDE) {
     if (getInfoFromFdeCie(fdeInfo, cieInfo, pc, sects.dso_base)) {

>From 7057f37bfdb4a03d230decc9a1306a461f4c0c08 Mon Sep 17 00:00:00 2001
From: Vyacheslav Chigrin <[email protected]>
Date: Thu, 13 Nov 2025 12:16:10 +0300
Subject: [PATCH 2/2] Fix formatting.

---
 libunwind/src/UnwindCursor.hpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 42c3cf9084219..e3cc1775686bc 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1813,11 +1813,11 @@ bool UnwindCursor<A, R>::getInfoFromDwarfSection(
       // Add to cache (to make next lookup faster) if we had no hint
       // and there was no index.
       if (!foundInCache && (fdeSectionOffsetHint == 0)) {
-  #if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
+#if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
         if (sects.dwarf_index_section == 0)
-  #endif
-        DwarfFDECache<A>::add(sects.dso_base, fdeInfo.pcStart, fdeInfo.pcEnd,
-                              fdeInfo.fdeStart);
+#endif
+          DwarfFDECache<A>::add(sects.dso_base, fdeInfo.pcStart, fdeInfo.pcEnd,
+                                fdeInfo.fdeStart);
       }
       return true;
     }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to