[PATCH] D135359: [lld-macho] Don't fold DWARFs with CompactUnwinds

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 6 06:15:56 PDT 2022


oontvoo created this revision.
Herald added a subscriber: kristof.beyls.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Mimic LD64's behaviour.
Drive-by cleanup: Rewrite the checking logic in InputFiles.cpp for clarity.
The previous form is currently "harmless" and happened to work (because there's no 0x05000000 in the enum set, but as soon as it's defined, it'll stop working)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135359

Files:
  lld/MachO/InputFiles.cpp
  lld/MachO/UnwindInfoSection.cpp


Index: lld/MachO/UnwindInfoSection.cpp
===================================================================
--- lld/MachO/UnwindInfoSection.cpp
+++ lld/MachO/UnwindInfoSection.cpp
@@ -397,6 +397,10 @@
                 static_cast<uint32_t>(UNWIND_X86_MODE_MASK));
   static_assert(static_cast<uint32_t>(UNWIND_X86_64_MODE_STACK_IND) ==
                 static_cast<uint32_t>(UNWIND_X86_MODE_STACK_IND));
+  // Can't fold DWARF sections.
+  if ((encoding & static_cast<uint32_t>(UNWIND_X86_64_MODE_MASK)) ==
+      target->modeDwarfEncoding)
+    return false;
   if ((target->cpuType == CPU_TYPE_X86_64 || target->cpuType == CPU_TYPE_X86) &&
       (encoding & UNWIND_X86_64_MODE_MASK) == UNWIND_X86_64_MODE_STACK_IND) {
     // FIXME: Consider passing in the two function addresses and getting
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -1096,7 +1096,12 @@
     // llvm-mc omits CU entries for functions that need DWARF encoding, but
     // `ld -r` doesn't. We can ignore them because we will re-synthesize these
     // CU entries from the DWARF info during the output phase.
-    if ((encoding & target->modeDwarfEncoding) == target->modeDwarfEncoding)
+    static_assert(static_cast<uint32_t>(UNWIND_X86_64_MODE_MASK) ==
+                      static_cast<uint32_t>(UNWIND_X86_MODE_MASK) &&
+                  static_cast < uint32_t(UNWIND_ARM64_MODE_MASK) ==
+                      static_cast<uint32_t>(UNWIND_X86_64_MODE_MASK));
+    if ((encoding & static_cast<uint32_t>(UNWIND_X86_64_MODE_MASK)) ==
+        target->modeDwarfEncoding)
       continue;
 
     ConcatInputSection *referentIsec;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135359.465710.patch
Type: text/x-patch
Size: 1720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221006/99ae425e/attachment.bin>


More information about the llvm-commits mailing list