Skip to content

Commit edae2e6

Browse files
Filter object file from CASOutputBackend in MCCAS.
When MCCAS is used, filter the object file from the CASOutputBackend because we do not want to write the object file in the CAS, we want to associate the MCCAS top level CAS Object to the main output of the CASOutputBackend.
1 parent 319f36b commit edae2e6

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,31 @@ void CompilerInstance::setupOutputBackend() {
474474

475475
// Mirror the output into CAS.
476476
if (supportCaching()) {
477+
auto &InAndOuts = Invocation.getFrontendOptions().InputsAndOutputs;
477478
CASOutputBackend = createSwiftCachingOutputBackend(
478-
*CAS, *ResultCache, *CompileJobBaseKey,
479-
Invocation.getFrontendOptions().InputsAndOutputs,
479+
*CAS, *ResultCache, *CompileJobBaseKey, InAndOuts,
480480
Invocation.getFrontendOptions().RequestedAction);
481+
482+
if (Invocation.getIRGenOptions().UseCASBackend) {
483+
auto OutputFiles = InAndOuts.copyOutputFilenames();
484+
std::unordered_set<std::string> OutputFileSet(
485+
std::make_move_iterator(OutputFiles.begin()),
486+
std::make_move_iterator(OutputFiles.end()));
487+
// Filter the object file output if MCCAS is enabled, we do not want to
488+
// store the object file itself, but store the MCCAS CASID instead.
489+
auto FilterBackend = llvm::vfs::makeFilteringOutputBackend(
490+
CASOutputBackend,
491+
[&, OutputFileSet](StringRef Path,
492+
std::optional<llvm::vfs::OutputConfig> Config) {
493+
if (InAndOuts.getPrincipalOutputType() != file_types::ID::TY_Object)
494+
return true;
495+
return !(OutputFileSet.find(Path.str()) != OutputFileSet.end());
496+
});
497+
OutputBackend =
498+
llvm::vfs::makeMirroringOutputBackend(OutputBackend, FilterBackend);
499+
return;
500+
}
501+
481502
OutputBackend =
482503
llvm::vfs::makeMirroringOutputBackend(OutputBackend, CASOutputBackend);
483504
}

0 commit comments

Comments
 (0)