@@ -847,6 +847,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
847847
848848 llvm::DIModule *getOrCreateModule (const void *Key, llvm::DIScope *Parent,
849849 StringRef Name, StringRef IncludePath,
850+ StringRef CompDir,
850851 uint64_t Signature = ~1ULL ,
851852 StringRef ASTFile = StringRef()) {
852853 // Look in the cache first.
@@ -856,6 +857,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
856857
857858 std::string RemappedIncludePath = DebugPrefixMap.remapPath (IncludePath);
858859 std::string RemappedASTFile = DebugPrefixMap.remapPath (ASTFile);
860+ std::string RemappedCompDir = DebugPrefixMap.remapPath (CompDir);
859861
860862 // For Clang modules / PCH, create a Skeleton CU pointing to the PCM/PCH.
861863 if (!Opts.DisableClangModuleSkeletonCUs ) {
@@ -865,7 +867,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
865867 llvm::DIBuilder DIB (M);
866868 DIB.createCompileUnit (IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC
867869 : llvm::dwarf::DW_LANG_C99,
868- DIB.createFile (Name, RemappedIncludePath ),
870+ DIB.createFile (Name, RemappedCompDir ),
869871 TheCU->getProducer (), true , StringRef (), 0 ,
870872 RemappedASTFile, llvm::DICompileUnit::FullDebug,
871873 Signature);
@@ -892,12 +894,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
892894 uint64_t Signature =
893895 Desc.getSignature () ? Desc.getSignature ().truncatedValue () : ~1ULL ;
894896
895- // Clang modules using fmodule-file-home-is-cwd should have their
896- // include path set to the working directory.
897- auto &HSI =
898- CI.getClangPreprocessor ().getHeaderSearchInfo ().getHeaderSearchOpts ();
899- StringRef IncludePath =
900- HSI.ModuleFileHomeIsCwd ? Opts.DebugCompilationDir : Desc.getPath ();
897+ StringRef CompDir = Opts.DebugCompilationDir ;
898+ StringRef IncludePath = Desc.getPath ();
901899
902900 // Handle Clang modules.
903901 if (ClangModule) {
@@ -919,12 +917,13 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
919917 ClangModule->Parent );
920918 }
921919 return getOrCreateModule (ClangModule, Parent, Desc.getModuleName (),
922- IncludePath, Signature, Desc.getASTFile ());
920+ IncludePath, CompDir, Signature,
921+ Desc.getASTFile ());
923922 }
924923 // Handle PCH.
925924 return getOrCreateModule (Desc.getASTFile ().bytes_begin (), nullptr ,
926- Desc.getModuleName (), IncludePath, Signature ,
927- Desc.getASTFile ());
925+ Desc.getModuleName (), IncludePath, CompDir ,
926+ Signature, Desc.getASTFile ());
928927 };
929928
930929 static std::optional<ASTSourceDescriptor>
@@ -947,7 +946,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
947946 // the module on disk is Bar (.swiftmodule or .swiftinterface), and is used
948947 // for loading and mangling.
949948 StringRef Name = M->getRealName ().str ();
950- return getOrCreateModule (M, TheCU, Name, Path);
949+ return getOrCreateModule (M, TheCU, Name, Path, Opts. DebugCompilationDir );
951950 }
952951
953952 TypeAliasDecl *getMetadataType (StringRef ArchetypeName) {
@@ -2543,8 +2542,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
25432542 auto Identifier = IGM.getSILModule ().getASTContext ().getIdentifier (
25442543 Attribute->ManglingModuleName );
25452544 void *Key = (void *)Identifier.get ();
2546- Scope =
2547- getOrCreateModule (Key, TheCU, Attribute-> ManglingModuleName , {});
2545+ Scope = getOrCreateModule (Key, TheCU, Attribute-> ManglingModuleName , {},
2546+ {});
25482547 } else {
25492548 Context = ND->getParent ();
25502549 }
@@ -2791,7 +2790,8 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
27912790 // Create a module for the current compile unit.
27922791 auto *MDecl = IGM.getSwiftModule ();
27932792 llvm::sys::path::remove_filename (SourcePath);
2794- MainModule = getOrCreateModule (MDecl, TheCU, Opts.ModuleName , SourcePath);
2793+ MainModule = getOrCreateModule (MDecl, TheCU, Opts.ModuleName , SourcePath,
2794+ Opts.DebugCompilationDir );
27952795 DBuilder.createImportedModule (MainFile, MainModule, MainFile, 0 );
27962796
27972797 // Macro definitions that were defined by the user with "-Xcc -D" on the
0 commit comments