Skip to content

Commit bb581a8

Browse files
authored
Merge pull request #81255 from artemcm/IncrementalScanFixes_62
[6.2 🍒][Dependency Scanning] Fix search path context hashing hole and avoid serializing unnecessary field
2 parents 8aca9b1 + b684af4 commit bb581a8

File tree

8 files changed

+144
-181
lines changed

8 files changed

+144
-181
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,6 @@ class ASTContext final {
10941094
/// $SDKROOT/System/Library/Frameworks/ and $SDKROOT/Library/Frameworks/.
10951095
std::vector<std::string> getDarwinImplicitFrameworkSearchPaths() const;
10961096

1097-
/// Return a set of all possible filesystem locations where modules can be found.
1098-
llvm::StringSet<> getAllModuleSearchPathsSet() const;
1099-
11001097
/// Load extensions to the given nominal type from the external
11011098
/// module loaders.
11021099
///

include/swift/AST/ModuleDependencies.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,6 @@ class ModuleDependencyInfo {
787787
return storage->auxiliaryFiles;
788788
}
789789

790-
void
791-
setAuxiliaryFiles(const ArrayRef<std::string> auxiliaryFiles) {
792-
storage->auxiliaryFiles.assign(auxiliaryFiles.begin(), auxiliaryFiles.end());
793-
}
794-
795790
bool isStaticLibrary() const {
796791
if (auto *detail = getAsSwiftInterfaceModule())
797792
return detail->isStatic;

include/swift/AST/SearchPathOptions.h

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ class SearchPathOptions {
323323
friend bool operator!=(const SearchPath &LHS, const SearchPath &RHS) {
324324
return !(LHS == RHS);
325325
}
326+
friend llvm::hash_code
327+
hash_value(const SearchPath &searchPath) {
328+
return llvm::hash_combine(searchPath.Path, searchPath.IsSystem);
329+
}
326330
};
327331

328332
private:
@@ -599,30 +603,17 @@ class SearchPathOptions {
599603
makeOverlayFileSystem(
600604
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) const;
601605

602-
private:
603-
static StringRef pathStringFromSearchPath(const SearchPath &next) {
604-
return next.Path;
605-
};
606-
607606
public:
608607
/// Return a hash code of any components from these options that should
609608
/// contribute to a Swift Bridging PCH hash.
610609
llvm::hash_code getPCHHashComponents() const {
611610
using llvm::hash_combine;
612611
using llvm::hash_combine_range;
613-
614-
using SearchPathView =
615-
ArrayRefView<SearchPath, StringRef, pathStringFromSearchPath>;
616-
SearchPathView importPathsOnly{ImportSearchPaths};
617-
SearchPathView frameworkPathsOnly{FrameworkSearchPaths};
618-
619612
return hash_combine(SDKPath,
620-
// FIXME: Should we include the system-ness of
621-
// search paths too?
622-
hash_combine_range(importPathsOnly.begin(), importPathsOnly.end()),
613+
hash_combine_range(ImportSearchPaths.begin(), ImportSearchPaths.end()),
623614
hash_combine_range(VFSOverlayFiles.begin(), VFSOverlayFiles.end()),
624-
hash_combine_range(frameworkPathsOnly.begin(),
625-
frameworkPathsOnly.end()),
615+
hash_combine_range(FrameworkSearchPaths.begin(),
616+
FrameworkSearchPaths.end()),
626617
hash_combine_range(LibrarySearchPaths.begin(),
627618
LibrarySearchPaths.end()),
628619
RuntimeResourcePath,

include/swift/DependencyScan/SerializedModuleDependencyCacheFormat.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using llvm::BCVBR;
4141
const unsigned char MODULE_DEPENDENCY_CACHE_FORMAT_SIGNATURE[] = {'I', 'M', 'D','C'};
4242
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR = 9;
4343
/// Increment this on every change.
44-
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR = 1;
44+
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR = 2;
4545

4646
/// Various identifiers in this format will rely on having their strings mapped
4747
/// using this ID.
@@ -80,7 +80,6 @@ using LinkLibrariesArrayIDField = IdentifierIDField;
8080
using MacroDependenciesArrayIDField = IdentifierIDField;
8181
using FlagIDArrayIDField = IdentifierIDField;
8282
using DependencyIDArrayIDField = IdentifierIDField;
83-
using AuxiliaryFilesArrayIDField = IdentifierIDField;
8483
using SourceLocationIDArrayIDField = IdentifierIDField;
8584

8685
/// The ID of the top-level block containing the dependency graph
@@ -204,8 +203,7 @@ using ModuleInfoLayout =
204203
DependencyIDArrayIDField, // importedClangModules
205204
DependencyIDArrayIDField, // crossImportOverlayModules
206205
DependencyIDArrayIDField, // swiftOverlayDependencies
207-
ModuleCacheKeyIDField, // moduleCacheKey
208-
AuxiliaryFilesArrayIDField // auxiliaryFiles
206+
ModuleCacheKeyIDField // moduleCacheKey
209207
>;
210208

211209
using SwiftInterfaceModuleDetailsLayout =

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,46 +2212,6 @@ const {
22122212
return SearchPathOpts.getDarwinImplicitFrameworkSearchPaths();
22132213
}
22142214

2215-
llvm::StringSet<> ASTContext::getAllModuleSearchPathsSet()
2216-
const {
2217-
llvm::StringSet<> result;
2218-
2219-
// Import and framework paths are "special", they contain more than path
2220-
// strings, but path strings are all we care about here.
2221-
using SearchPathView = ArrayRefView<SearchPathOptions::SearchPath, StringRef,
2222-
pathStringFromSearchPath>;
2223-
2224-
SearchPathView importPathsOnly{SearchPathOpts.getImportSearchPaths()};
2225-
result.insert(importPathsOnly.begin(), importPathsOnly.end());
2226-
2227-
SearchPathView frameworkPathsOnly{SearchPathOpts.getFrameworkSearchPaths()};
2228-
result.insert(frameworkPathsOnly.begin(), frameworkPathsOnly.end());
2229-
2230-
if (LangOpts.Target.isOSDarwin()) {
2231-
auto implicitFrameworkSearchPaths = getDarwinImplicitFrameworkSearchPaths();
2232-
result.insert(implicitFrameworkSearchPaths.begin(),
2233-
implicitFrameworkSearchPaths.end());
2234-
}
2235-
result.insert(SearchPathOpts.RuntimeLibraryImportPaths.begin(),
2236-
SearchPathOpts.RuntimeLibraryImportPaths.end());
2237-
2238-
// ClangImporter special-cases the path for SwiftShims, so do the same here
2239-
// If there are no shims in the resource dir, add a search path in the SDK.
2240-
SmallString<128> shimsPath(SearchPathOpts.RuntimeResourcePath);
2241-
llvm::sys::path::append(shimsPath, "shims");
2242-
if (!llvm::sys::fs::exists(shimsPath)) {
2243-
shimsPath = SearchPathOpts.getSDKPath();
2244-
llvm::sys::path::append(shimsPath, "usr", "lib", "swift", "shims");
2245-
}
2246-
result.insert(shimsPath.str());
2247-
2248-
// Clang system modules are found in the SDK root
2249-
SmallString<128> clangSysRootPath(SearchPathOpts.getSDKPath());
2250-
llvm::sys::path::append(clangSysRootPath, "usr", "include");
2251-
result.insert(clangSysRootPath.str());
2252-
return result;
2253-
}
2254-
22552215
void ASTContext::loadExtensions(NominalTypeDecl *nominal,
22562216
unsigned previousGeneration) {
22572217
PrettyStackTraceDecl stackTrace("loading extensions for", nominal);

0 commit comments

Comments
 (0)