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 c8fa4dbeffb9e..b9d1043276a60 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" @@ -771,6 +772,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. @@ -779,6 +781,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 + "'");