From f344e535f3ea5fec71a9644d82ef7a1a798f3457 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 22 May 2017 11:53:12 -0700 Subject: [PATCH] Debug info: Avoid emitting module imports twice when access path differs. This fixes a recent regression from 68a5cadb90e. rdar://problem/32327266 --- lib/IRGen/IRGenDebugInfo.cpp | 6 +++--- test/DebugInfo/ImportClangSubmodule.swift | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 805b78c58ee5a..304c66f575cf3 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -97,7 +97,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { /// A list of replaceable fwddecls that need to be RAUWed at the end. std::vector> ReplaceMap; /// The set of imported modules. - llvm::DenseSet ImportedModules; + llvm::DenseSet ImportedModules; llvm::BumpPtrAllocator DebugInfoNames; StringRef CWDName; /// The current working directory. @@ -1558,7 +1558,7 @@ void IRGenDebugInfoImpl::finalize() { IGM.getSwiftModule()->getImportedModules(ModuleWideImports, ModuleDecl::ImportFilter::All); for (auto M : ModuleWideImports) - if (!ImportedModules.count(M)) + if (!ImportedModules.count(M.second)) DBuilder.createImportedModule(MainFile, getOrCreateModule(M), 0); // Finalize all replaceable forward declarations. @@ -1731,7 +1731,7 @@ void IRGenDebugInfoImpl::emitImport(ImportDecl *D) { auto DIMod = getOrCreateModule(Imported); auto L = getDebugLoc(*this, D); DBuilder.createImportedModule(getOrCreateFile(L.Filename), DIMod, L.Line); - ImportedModules.insert(Imported); + ImportedModules.insert(Imported.second); } llvm::DISubprogram *IRGenDebugInfoImpl::emitFunction(SILFunction &SILFn, diff --git a/test/DebugInfo/ImportClangSubmodule.swift b/test/DebugInfo/ImportClangSubmodule.swift index a84a09532b844..9fc4a27c3f025 100644 --- a/test/DebugInfo/ImportClangSubmodule.swift +++ b/test/DebugInfo/ImportClangSubmodule.swift @@ -16,6 +16,8 @@ import ClangModule.SubModule // The Swift compiler uses an ugly hack that auto-imports a // submodule's top-level-module, even if we didn't ask for it. +// CHECK-NOT: !DIImportedEntity({{.*}}, entity: ![[SUBMODULE]] // CHECK: !DIImportedEntity({{.*}}, entity: ![[CLANGMODULE]]) +// CHECK-NOT: !DIImportedEntity({{.*}}, entity: ![[SUBMODULE]] let bar = Bar()