@@ -864,13 +864,25 @@ class ParseableInterfaceModuleLoaderImpl {
864
864
if (isForwardingModule) {
865
865
if (auto forwardingModule = ForwardingModule::load (*buf)) {
866
866
std::unique_ptr<llvm::MemoryBuffer> moduleBuffer;
867
- if (forwardingModuleIsUpToDate (*forwardingModule, deps, moduleBuffer))
867
+ if (forwardingModuleIsUpToDate (*forwardingModule, deps,
868
+ moduleBuffer)) {
869
+ LLVM_DEBUG (llvm::dbgs () << " Found up-to-date forwarding module at "
870
+ << cachedOutputPath << " \n " );
868
871
return DiscoveredModule::forwarded (
869
872
forwardingModule->underlyingModulePath , std::move (moduleBuffer));
873
+ }
874
+
875
+ LLVM_DEBUG (llvm::dbgs () << " Found out-of-date forwarding module at "
876
+ << cachedOutputPath << " \n " );
870
877
}
871
878
// Otherwise, check if the AST buffer itself is up to date.
872
879
} else if (serializedASTBufferIsUpToDate (*buf, deps)) {
880
+ LLVM_DEBUG (llvm::dbgs () << " Found up-to-date cached module at "
881
+ << cachedOutputPath << " \n " );
873
882
return DiscoveredModule::normal (cachedOutputPath, std::move (buf));
883
+ } else {
884
+ LLVM_DEBUG (llvm::dbgs () << " Found out-of-date cached module at "
885
+ << cachedOutputPath << " \n " );
874
886
}
875
887
}
876
888
@@ -883,23 +895,39 @@ class ParseableInterfaceModuleLoaderImpl {
883
895
llvm::SmallString<256 > scratch;
884
896
std::unique_ptr<llvm::MemoryBuffer> moduleBuffer;
885
897
auto path = computePrebuiltModulePath (scratch);
886
- if (path && swiftModuleIsUpToDate (*path, deps, moduleBuffer))
887
- return DiscoveredModule::prebuilt (*path, std::move (moduleBuffer));
898
+ if (path) {
899
+ if (swiftModuleIsUpToDate (*path, deps, moduleBuffer)) {
900
+ LLVM_DEBUG (llvm::dbgs () << " Found up-to-date prebuilt module at "
901
+ << path->str () << " \n " );
902
+ return DiscoveredModule::prebuilt (*path, std::move (moduleBuffer));
903
+ } else {
904
+ LLVM_DEBUG (llvm::dbgs () << " Found out-of-date prebuilt module at "
905
+ << modulePath << " \n " );
906
+ }
907
+ }
888
908
}
889
909
890
910
// Finally, if there's a module adjacent to the .swiftinterface that we can
891
911
// _likely_ load (it validates OK and is up to date), bail early with
892
912
// errc::not_supported, so the next (serialized) loader in the chain will
893
- // load it. Alternately, if there's a .swiftmodule present but we can't even
913
+ // load it.
914
+ // Alternately, if there's a .swiftmodule present but we can't even
894
915
// read it (for whatever reason), we should let the other module loader
895
916
// diagnose it.
896
917
if (!shouldLoadAdjacentModule)
897
918
return notFoundError;
898
919
899
920
auto adjacentModuleBuffer = fs.getBufferForFile (modulePath);
900
921
if (adjacentModuleBuffer) {
901
- if (serializedASTBufferIsUpToDate (*adjacentModuleBuffer.get (), deps))
922
+ if (serializedASTBufferIsUpToDate (*adjacentModuleBuffer.get (), deps)) {
923
+ LLVM_DEBUG (llvm::dbgs () << " Found up-to-date module at "
924
+ << modulePath
925
+ << " ; deferring to serialized module loader\n " );
902
926
return std::make_error_code (std::errc::not_supported);
927
+ } else {
928
+ LLVM_DEBUG (llvm::dbgs () << " Found out-of-date module at "
929
+ << modulePath << " \n " );
930
+ }
903
931
} else if (adjacentModuleBuffer.getError () != notFoundError) {
904
932
return std::make_error_code (std::errc::not_supported);
905
933
}
@@ -1053,8 +1081,15 @@ std::error_code ParseableInterfaceModuleLoader::findModuleFilesInDirectory(
1053
1081
auto Ext = file_types::getExtension (file_types::TY_SwiftParseableInterfaceFile);
1054
1082
InPath = ModPath;
1055
1083
path::replace_extension (InPath, Ext);
1056
- if (!fs.exists (InPath))
1084
+ if (!fs.exists (InPath)) {
1085
+ if (fs.exists (ModPath)) {
1086
+ LLVM_DEBUG (llvm::dbgs ()
1087
+ << " No .swiftinterface file found adjacent to module file "
1088
+ << ModPath.str () << " \n " );
1089
+ return std::make_error_code (std::errc::not_supported);
1090
+ }
1057
1091
return std::make_error_code (std::errc::no_such_file_or_directory);
1092
+ }
1058
1093
1059
1094
// Create an instance of the Impl to do the heavy lifting.
1060
1095
ParseableInterfaceModuleLoaderImpl Impl (
0 commit comments