Skip to content

Commit 9eeae5a

Browse files
[dsymutil] Deduplicate Swift modules by path before copying them (llvm#139342)
1 parent c870b67 commit 9eeae5a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

llvm/test/tools/dsymutil/ARM/swiftmodule.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#
1414
# CHECK-NOT: Skipping compiled textual Swift interface: {{.*}}/Inputs/Binary.swiftmodule
1515
# CHECK: Skipping compiled textual Swift interface: {{.*}}/Inputs/FromInterface.swiftmodule
16+
# CHECK-NOT: Skipping compiled textual Swift interface: {{.*}}/Inputs/FromInterface.swiftmodule
1617

1718
#
1819
---
@@ -26,4 +27,8 @@ objects:
2627
timestamp: 0
2728
type: 50
2829
symbols: []
30+
- filename: '../Inputs/FromInterface.swiftmodule'
31+
timestamp: 0
32+
type: 50
33+
symbols: []
2934
...

llvm/tools/dsymutil/DwarfLinkerForBinary.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/ADT/STLExtras.h"
2020
#include "llvm/ADT/SmallString.h"
2121
#include "llvm/ADT/StringRef.h"
22+
#include "llvm/ADT/StringSet.h"
2223
#include "llvm/ADT/Twine.h"
2324
#include "llvm/BinaryFormat/Dwarf.h"
2425
#include "llvm/BinaryFormat/MachO.h"
@@ -769,6 +770,7 @@ bool DwarfLinkerForBinary::linkImpl(
769770
MaxDWARFVersion = std::max(Unit.getVersion(), MaxDWARFVersion);
770771
};
771772

773+
llvm::StringSet<> SwiftModules;
772774
for (const auto &Obj : Map.objects()) {
773775
// N_AST objects (swiftmodule files) should get dumped directly into the
774776
// appropriate DWARF section.
@@ -777,6 +779,9 @@ bool DwarfLinkerForBinary::linkImpl(
777779
outs() << "DEBUG MAP OBJECT: " << Obj->getObjectFilename() << "\n";
778780

779781
StringRef File = Obj->getObjectFilename();
782+
if (!SwiftModules.insert(File).second)
783+
continue;
784+
780785
auto ErrorOrMem = MemoryBuffer::getFile(File);
781786
if (!ErrorOrMem) {
782787
reportWarning("Could not open '" + File + "'");

0 commit comments

Comments
 (0)