@@ -880,13 +880,25 @@ class ParseableInterfaceModuleLoaderImpl {
880
880
if (isForwardingModule) {
881
881
if (auto forwardingModule = ForwardingModule::load (*buf)) {
882
882
std::unique_ptr<llvm::MemoryBuffer> moduleBuffer;
883
- if (forwardingModuleIsUpToDate (*forwardingModule, deps, moduleBuffer))
883
+ if (forwardingModuleIsUpToDate (*forwardingModule, deps,
884
+ moduleBuffer)) {
885
+ LLVM_DEBUG (llvm::dbgs () << " Found up-to-date forwarding module at "
886
+ << cachedOutputPath << " \n " );
884
887
return DiscoveredModule::forwarded (
885
888
forwardingModule->underlyingModulePath , std::move (moduleBuffer));
889
+ }
890
+
891
+ LLVM_DEBUG (llvm::dbgs () << " Found out-of-date forwarding module at "
892
+ << cachedOutputPath << " \n " );
886
893
}
887
894
// Otherwise, check if the AST buffer itself is up to date.
888
895
} else if (serializedASTBufferIsUpToDate (*buf, deps)) {
896
+ LLVM_DEBUG (llvm::dbgs () << " Found up-to-date cached module at "
897
+ << cachedOutputPath << " \n " );
889
898
return DiscoveredModule::normal (cachedOutputPath, std::move (buf));
899
+ } else {
900
+ LLVM_DEBUG (llvm::dbgs () << " Found out-of-date cached module at "
901
+ << cachedOutputPath << " \n " );
890
902
}
891
903
}
892
904
@@ -899,23 +911,39 @@ class ParseableInterfaceModuleLoaderImpl {
899
911
llvm::SmallString<256 > scratch;
900
912
std::unique_ptr<llvm::MemoryBuffer> moduleBuffer;
901
913
auto path = computePrebuiltModulePath (scratch);
902
- if (path && swiftModuleIsUpToDate (*path, deps, moduleBuffer))
903
- return DiscoveredModule::prebuilt (*path, std::move (moduleBuffer));
914
+ if (path) {
915
+ if (swiftModuleIsUpToDate (*path, deps, moduleBuffer)) {
916
+ LLVM_DEBUG (llvm::dbgs () << " Found up-to-date prebuilt module at "
917
+ << path->str () << " \n " );
918
+ return DiscoveredModule::prebuilt (*path, std::move (moduleBuffer));
919
+ } else {
920
+ LLVM_DEBUG (llvm::dbgs () << " Found out-of-date prebuilt module at "
921
+ << modulePath << " \n " );
922
+ }
923
+ }
904
924
}
905
925
906
926
// Finally, if there's a module adjacent to the .swiftinterface that we can
907
927
// _likely_ load (it validates OK and is up to date), bail early with
908
928
// errc::not_supported, so the next (serialized) loader in the chain will
909
- // load it. Alternately, if there's a .swiftmodule present but we can't even
929
+ // load it.
930
+ // Alternately, if there's a .swiftmodule present but we can't even
910
931
// read it (for whatever reason), we should let the other module loader
911
932
// diagnose it.
912
933
if (!shouldLoadAdjacentModule)
913
934
return notFoundError;
914
935
915
936
auto adjacentModuleBuffer = fs.getBufferForFile (modulePath);
916
937
if (adjacentModuleBuffer) {
917
- if (serializedASTBufferIsUpToDate (*adjacentModuleBuffer.get (), deps))
938
+ if (serializedASTBufferIsUpToDate (*adjacentModuleBuffer.get (), deps)) {
939
+ LLVM_DEBUG (llvm::dbgs () << " Found up-to-date module at "
940
+ << modulePath
941
+ << " ; deferring to serialized module loader\n " );
918
942
return std::make_error_code (std::errc::not_supported);
943
+ } else {
944
+ LLVM_DEBUG (llvm::dbgs () << " Found out-of-date module at "
945
+ << modulePath << " \n " );
946
+ }
919
947
} else if (adjacentModuleBuffer.getError () != notFoundError) {
920
948
return std::make_error_code (std::errc::not_supported);
921
949
}
@@ -1070,8 +1098,15 @@ std::error_code ParseableInterfaceModuleLoader::findModuleFilesInDirectory(
1070
1098
auto Ext = file_types::getExtension (file_types::TY_SwiftParseableInterfaceFile);
1071
1099
InPath = ModPath;
1072
1100
path::replace_extension (InPath, Ext);
1073
- if (!fs.exists (InPath))
1101
+ if (!fs.exists (InPath)) {
1102
+ if (fs.exists (ModPath)) {
1103
+ LLVM_DEBUG (llvm::dbgs ()
1104
+ << " No .swiftinterface file found adjacent to module file "
1105
+ << ModPath.str () << " \n " );
1106
+ return std::make_error_code (std::errc::not_supported);
1107
+ }
1074
1108
return std::make_error_code (std::errc::no_such_file_or_directory);
1109
+ }
1075
1110
1076
1111
// Create an instance of the Impl to do the heavy lifting.
1077
1112
ParseableInterfaceModuleLoaderImpl Impl (
0 commit comments