[llvm] 9eeae5a - [dsymutil] Deduplicate Swift modules by path before copying them (#139342)

via llvm-commits llvm-commits at lists.llvm.org
Sun May 11 08:36:32 PDT 2025


Author: Adrian Prantl
Date: 2025-05-11T08:36:28-07:00
New Revision: 9eeae5a5de41b22d31d9037be2acc45dd7af4192

URL: https://github.com/llvm/llvm-project/commit/9eeae5a5de41b22d31d9037be2acc45dd7af4192
DIFF: https://github.com/llvm/llvm-project/commit/9eeae5a5de41b22d31d9037be2acc45dd7af4192.diff

LOG: [dsymutil] Deduplicate Swift modules by path before copying them (#139342)

Added: 
    

Modified: 
    llvm/test/tools/dsymutil/ARM/swiftmodule.test
    llvm/tools/dsymutil/DwarfLinkerForBinary.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/dsymutil/ARM/swiftmodule.test b/llvm/test/tools/dsymutil/ARM/swiftmodule.test
index 347f2841655ef..31b392610c091 100644
--- a/llvm/test/tools/dsymutil/ARM/swiftmodule.test
+++ b/llvm/test/tools/dsymutil/ARM/swiftmodule.test
@@ -13,6 +13,7 @@
 #
 # CHECK-NOT: Skipping compiled textual Swift interface: {{.*}}/Inputs/Binary.swiftmodule
 # CHECK: Skipping compiled textual Swift interface: {{.*}}/Inputs/FromInterface.swiftmodule
+# CHECK-NOT: Skipping compiled textual Swift interface: {{.*}}/Inputs/FromInterface.swiftmodule
 
 #
 ---
@@ -26,4 +27,8 @@ objects:
     timestamp:       0
     type:            50
     symbols:         []
+  - filename:        '../Inputs/FromInterface.swiftmodule'
+    timestamp:       0
+    type:            50
+    symbols:         []
 ...

diff  --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index 9bcc479f9bef5..e88e076dca996 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/BinaryFormat/MachO.h"
@@ -769,6 +770,7 @@ bool DwarfLinkerForBinary::linkImpl(
         MaxDWARFVersion = std::max(Unit.getVersion(), MaxDWARFVersion);
       };
 
+  llvm::StringSet<> SwiftModules;
   for (const auto &Obj : Map.objects()) {
     // N_AST objects (swiftmodule files) should get dumped directly into the
     // appropriate DWARF section.
@@ -777,6 +779,9 @@ bool DwarfLinkerForBinary::linkImpl(
         outs() << "DEBUG MAP OBJECT: " << Obj->getObjectFilename() << "\n";
 
       StringRef File = Obj->getObjectFilename();
+      if (!SwiftModules.insert(File).second)
+        continue;
+
       auto ErrorOrMem = MemoryBuffer::getFile(File);
       if (!ErrorOrMem) {
         reportWarning("Could not open '" + File + "'");


        


More information about the llvm-commits mailing list