mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Caching] Reduce the number of cas ID passed on frontend commandline
Using IncludeTree::FileList to concat the include tree file systems that are passed on the command-line. This significantly reduce the command-line size, and also makes the cache key computation a lot faster. rdar://148752988
This commit is contained in:
@@ -472,16 +472,10 @@ static Expected<ObjectRef> mergeCASFileSystem(ObjectStore &CAS,
|
||||
|
||||
Expected<IntrusiveRefCntPtr<vfs::FileSystem>>
|
||||
createCASFileSystem(ObjectStore &CAS, ArrayRef<std::string> FSRoots,
|
||||
ArrayRef<std::string> IncludeTrees,
|
||||
ArrayRef<std::string> IncludeTreeFileList) {
|
||||
assert(!FSRoots.empty() || !IncludeTrees.empty() ||
|
||||
const std::string &IncludeTree,
|
||||
const std::string &IncludeTreeFileList) {
|
||||
assert(!FSRoots.empty() || !IncludeTree.empty() ||
|
||||
!IncludeTreeFileList.empty() && "no root ID provided");
|
||||
if (FSRoots.size() == 1 && IncludeTrees.empty()) {
|
||||
auto ID = CAS.parseID(FSRoots.front());
|
||||
if (!ID)
|
||||
return ID.takeError();
|
||||
return createCASFileSystem(CAS, *ID);
|
||||
}
|
||||
|
||||
auto NewRoot = mergeCASFileSystem(CAS, FSRoots);
|
||||
if (!NewRoot)
|
||||
@@ -492,10 +486,9 @@ createCASFileSystem(ObjectStore &CAS, ArrayRef<std::string> FSRoots,
|
||||
return FS.takeError();
|
||||
|
||||
auto CASFS = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(std::move(*FS));
|
||||
std::vector<clang::cas::IncludeTree::FileList::FileEntry> Files;
|
||||
// Push all Include File System onto overlay.
|
||||
for (auto &Tree : IncludeTrees) {
|
||||
auto ID = CAS.parseID(Tree);
|
||||
|
||||
if (!IncludeTree.empty()) {
|
||||
auto ID = CAS.parseID(IncludeTree);
|
||||
if (!ID)
|
||||
return ID.takeError();
|
||||
|
||||
@@ -510,46 +503,32 @@ createCASFileSystem(ObjectStore &CAS, ArrayRef<std::string> FSRoots,
|
||||
if (!ITF)
|
||||
return ITF.takeError();
|
||||
|
||||
auto Err = ITF->forEachFile(
|
||||
[&](clang::cas::IncludeTree::File File,
|
||||
clang::cas::IncludeTree::FileList::FileSizeTy Size) -> llvm::Error {
|
||||
Files.push_back({File.getRef(), Size});
|
||||
return llvm::Error::success();
|
||||
});
|
||||
auto ITFS = clang::cas::createIncludeTreeFileSystem(*ITF);
|
||||
if (!ITFS)
|
||||
return ITFS.takeError();
|
||||
|
||||
if (Err)
|
||||
return std::move(Err);
|
||||
CASFS->pushOverlay(*ITFS);
|
||||
}
|
||||
|
||||
for (auto &List: IncludeTreeFileList) {
|
||||
auto ID = CAS.parseID(List);
|
||||
if (!IncludeTreeFileList.empty()) {
|
||||
auto ID = CAS.parseID(IncludeTreeFileList);
|
||||
if (!ID)
|
||||
return ID.takeError();
|
||||
|
||||
auto Ref = CAS.getReference(*ID);
|
||||
if (!Ref)
|
||||
return createCASObjectNotFoundError(*ID);
|
||||
auto IT = clang::cas::IncludeTree::FileList::get(CAS, *Ref);
|
||||
if (!IT)
|
||||
return IT.takeError();
|
||||
auto ITF = clang::cas::IncludeTree::FileList::get(CAS, *Ref);
|
||||
if (!ITF)
|
||||
return ITF.takeError();
|
||||
|
||||
auto Err = IT->forEachFile(
|
||||
[&](clang::cas::IncludeTree::File File,
|
||||
clang::cas::IncludeTree::FileList::FileSizeTy Size) -> llvm::Error {
|
||||
Files.push_back({File.getRef(), Size});
|
||||
return llvm::Error::success();
|
||||
});
|
||||
auto ITFS = clang::cas::createIncludeTreeFileSystem(*ITF);
|
||||
if (!ITFS)
|
||||
return ITFS.takeError();
|
||||
|
||||
if (Err)
|
||||
return std::move(Err);
|
||||
CASFS->pushOverlay(std::move(*ITFS));
|
||||
}
|
||||
|
||||
auto ITFS = clang::cas::createIncludeTreeFileSystem(CAS, Files);
|
||||
if (!ITFS)
|
||||
return ITFS.takeError();
|
||||
|
||||
CASFS->pushOverlay(std::move(*ITFS));
|
||||
|
||||
return CASFS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user