[llvm] [DWARFLinker] Record the raw DW_AT_language on CompileUnit (PR #195475)

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Sat May 2 11:43:02 PDT 2026


https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/195475

CompileUnit::Language was populated only for ODR-eligible languages: the constructor ran the DW_AT_language value through isODRLanguage and stored std::nullopt otherwise. Downstream code that needed the raw language (like the Swift check) early-exited and never reached the Swift branch, so the parallel linker silently skipped parseable Swift interface recording and the subsequent warnings.

Store DW_AT_language as read from the input and apply isODRLanguage at the single site that cares. C/C++ ODR behavior is unchanged; Swift (and other non-ODR languages) now get a populated Language so analyzeImportedModule can inspect it.

>From eee057f50c4ead213c212d3df954a02bbd44edb8 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Sat, 2 May 2026 11:40:47 -0700
Subject: [PATCH] [DWARFLinker] Record the raw DW_AT_language on CompileUnit

CompileUnit::Language was populated only for ODR-eligible languages:
the constructor ran the DW_AT_language value through isODRLanguage and
stored std::nullopt otherwise. Downstream code that needed the raw
language (like the Swift check) early-exited and never reached the
Swift branch, so the parallel linker silently skipped parseable Swift
interface recording and the subsequent warnings.

Store DW_AT_language as read from the input and apply isODRLanguage at
the single site that cares. C/C++ ODR behavior is unchanged; Swift (and
other non-ODR languages) now get a populated Language so
analyzeImportedModule can inspect it.
---
 .../DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp   | 10 ++++------
 .../lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h |  2 +-
 llvm/test/tools/dsymutil/X86/swift-interface.test     | 11 +++++++++--
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
index 1e16716b29082..13fd9b0bece5b 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
@@ -51,13 +51,11 @@ CompileUnit::CompileUnit(LinkingGlobalData &GlobalData, DWARFUnit &OrigUnit,
   if (!CUDie)
     return;
 
-  if (std::optional<DWARFFormValue> Val = CUDie.find(dwarf::DW_AT_language)) {
-    uint16_t LangVal = dwarf::toUnsigned(Val, 0);
-    if (isODRLanguage(LangVal))
-      Language = LangVal;
-  }
+  if (std::optional<DWARFFormValue> Val = CUDie.find(dwarf::DW_AT_language))
+    Language = dwarf::toUnsigned(Val, 0);
 
-  if (!GlobalData.getOptions().NoODR && Language.has_value())
+  if (!GlobalData.getOptions().NoODR && Language.has_value() &&
+      isODRLanguage(*Language))
     NoODR = false;
 
   if (const char *CUName = CUDie.getName(DINameKind::ShortName))
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h
index 1c4a62c06934d..cb178dce8fb27 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h
@@ -681,7 +681,7 @@ class alignas(8) CompileUnit : public DwarfUnit {
   /// Pointer to the paired compile unit from the input DWARF.
   DWARFUnit *OrigUnit = nullptr;
 
-  /// The DW_AT_language of this unit.
+  /// Raw DW_AT_language from the input (not ODR-filtered).
   std::optional<uint16_t> Language;
 
   /// Line table for this unit.
diff --git a/llvm/test/tools/dsymutil/X86/swift-interface.test b/llvm/test/tools/dsymutil/X86/swift-interface.test
index d64b61070567e..bf03b5a804bfd 100644
--- a/llvm/test/tools/dsymutil/X86/swift-interface.test
+++ b/llvm/test/tools/dsymutil/X86/swift-interface.test
@@ -6,11 +6,20 @@
 # RUN: dsymutil --linker classic -oso-prepend-path %t.dir -y %s \
 # RUN:    -o %t.dir/swift-interface.dSYM 2>&1 \
 # RUN:    | FileCheck %s --check-prefix=WARNINGS
+# RUN: rm -rf %t.dir/swift-interface.dSYM
+# RUN: dsymutil --linker parallel -oso-prepend-path %t.dir -y %s \
+# RUN:    -o %t.dir/swift-interface.dSYM 2>&1 \
+# RUN:    | FileCheck %s --check-prefix=WARNINGS
 # RUN: echo "// module Foo" >%t.dir/Foo/x86_64.swiftinterface
 # RUN: dsymutil --linker classic -oso-prepend-path %t.dir -y %s \
 # RUN:    -o %t.dir/swift-interface.dSYM
 # RUN: cat %t.dir/swift-interface.dSYM/Contents/Resources/Swift/x86_64/Foo.swiftinterface \
 # RUN:   | FileCheck %s --check-prefix=INTERFACE
+# RUN: rm -rf %t.dir/swift-interface.dSYM
+# RUN: dsymutil --linker parallel -oso-prepend-path %t.dir -y %s \
+# RUN:    -o %t.dir/swift-interface.dSYM
+# RUN: cat %t.dir/swift-interface.dSYM/Contents/Resources/Swift/x86_64/Foo.swiftinterface \
+# RUN:   | FileCheck %s --check-prefix=INTERFACE
 
 # WARNINGS-NOT: cannot copy parseable Swift interface {{.*}}{{Swift|Foundation|_Concurrency}}
 # WARNINGS: cannot copy parseable Swift interface {{.*}}Foo
@@ -24,5 +33,3 @@ objects:
     symbols:
       - { sym: _main, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }
 ...
-
-## FIXME: Support --linker parallel



More information about the llvm-commits mailing list