@@ -864,7 +864,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
864864 llvm::DIModule *getOrCreateModule (const void *Key, llvm::DIScope *Parent,
865865 StringRef Name, StringRef IncludePath,
866866 uint64_t Signature = ~1ULL ,
867- StringRef ASTFile = StringRef() ) {
867+ StringRef ASTFile = {} ) {
868868 // Look in the cache first.
869869 auto Val = DIModuleCache.find (Key);
870870 if (Val != DIModuleCache.end ())
@@ -2823,8 +2823,12 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
28232823
28242824 // Create a module for the current compile unit.
28252825 auto *MDecl = IGM.getSwiftModule ();
2826- llvm::sys::path::remove_filename (SourcePath);
2827- MainModule = getOrCreateModule (MDecl, TheCU, Opts.ModuleName , SourcePath);
2826+ StringRef Path = Opts.DebugModulePath ;
2827+ if (Path.empty ()) {
2828+ llvm::sys::path::remove_filename (SourcePath);
2829+ Path = SourcePath;
2830+ }
2831+ MainModule = getOrCreateModule (MDecl, TheCU, Opts.ModuleName , Path);
28282832 DBuilder.createImportedModule (MainFile, MainModule, MainFile, 0 );
28292833
28302834 // Macro definitions that were defined by the user with "-Xcc -D" on the
0 commit comments