mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Virtualize swiftconstvalues output
Virtualize swiftconstvalues output so it can be cached inside CAS.
This commit is contained in:
@@ -55,7 +55,7 @@ gatherConstValuesForModule(const std::unordered_set<std::string> &Protocols,
|
||||
/// Serialize a collection of \c ConstValueInfos to JSON at the
|
||||
/// provided output stream.
|
||||
bool writeAsJSONToFile(const std::vector<ConstValueTypeInfo> &ConstValueInfos,
|
||||
llvm::raw_fd_ostream &OS);
|
||||
llvm::raw_ostream &OS);
|
||||
} // namespace swift
|
||||
|
||||
#endif
|
||||
|
||||
@@ -804,7 +804,7 @@ void writeAttrInformation(llvm::json::OStream &JSON,
|
||||
}
|
||||
|
||||
bool writeAsJSONToFile(const std::vector<ConstValueTypeInfo> &ConstValueInfos,
|
||||
llvm::raw_fd_ostream &OS) {
|
||||
llvm::raw_ostream &OS) {
|
||||
llvm::json::OStream JSON(OS, 2);
|
||||
JSON.array([&] {
|
||||
for (const auto &TypeInfo : ConstValueInfos) {
|
||||
|
||||
@@ -726,10 +726,12 @@ static bool emitConstValuesForWholeModuleIfNeeded(
|
||||
return true;
|
||||
auto ConstValues = gatherConstValuesForModule(Protocols,
|
||||
Instance.getMainModule());
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream OS(ConstValuesFilePath, EC, llvm::sys::fs::OF_None);
|
||||
|
||||
return withOutputPath(Instance.getDiags(), Instance.getOutputBackend(),
|
||||
ConstValuesFilePath, [&](llvm::raw_ostream &OS) {
|
||||
writeAsJSONToFile(ConstValues, OS);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
static void emitConstValuesForAllPrimaryInputsIfNeeded(
|
||||
@@ -755,9 +757,11 @@ static void emitConstValuesForAllPrimaryInputsIfNeeded(
|
||||
continue;
|
||||
|
||||
auto ConstValues = gatherConstValuesForPrimary(Protocols, SF);
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream OS(ConstValuesFilePath, EC, llvm::sys::fs::OF_None);
|
||||
withOutputPath(Instance.getDiags(), Instance.getOutputBackend(),
|
||||
ConstValuesFilePath, [&](llvm::raw_ostream &OS) {
|
||||
writeAsJSONToFile(ConstValues, OS);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,9 +776,12 @@ static bool writeModuleSemanticInfoIfNeeded(CompilerInstance &Instance) {
|
||||
auto ModuleSemanticPath = frontendOpts.InputsAndOutputs
|
||||
.getPrimarySpecificPathsForAtMostOnePrimary().SupplementaryOutputs
|
||||
.ModuleSemanticInfoOutputPath;
|
||||
llvm::raw_fd_ostream OS(ModuleSemanticPath, EC, llvm::sys::fs::OF_None);
|
||||
|
||||
return withOutputPath(Instance.getDiags(), Instance.getOutputBackend(),
|
||||
ModuleSemanticPath, [&](llvm::raw_ostream &OS) {
|
||||
OS << "{}\n";
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
static bool writeTBDIfNeeded(CompilerInstance &Instance) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -module-name test -emit-module -o %t/test.swiftmodule -primary-file %s -emit-module-doc-path %t/test.docc -enable-deterministic-check 2>&1 | %FileCheck %s --check-prefix=MODULE_OUTPUT --check-prefix=DOCC_OUTPUT
|
||||
// RUN: echo '[]' > %t/protocol.json
|
||||
// RUN: %target-swift-frontend -module-name test -emit-module -o %t/test.swiftmodule -primary-file %s -emit-module-doc-path %t/test.docc -const-gather-protocols-file %t/protocol.json -emit-const-values-path %t/test.swiftconstvalues -enable-deterministic-check 2>&1 | %FileCheck %s --check-prefix=MODULE_OUTPUT --check-prefix=DOCC_OUTPUT --check-prefix=CONSTVALUE_OUTPUT
|
||||
// RUN: %target-swift-frontend -module-name test -emit-sib -o %t/test.sib -primary-file %s -enable-deterministic-check 2>&1 | %FileCheck %s --check-prefix=SIB_OUTPUT
|
||||
|
||||
/// object files are "not" deterministic because the second run going to match the mod hash and skip code generation.
|
||||
@@ -25,6 +26,7 @@
|
||||
// RUN: %target-swift-frontend -emit-pcm -module-name UserClangModule -o %t/test.pcm %S/Inputs/dependencies/module.modulemap -enable-deterministic-check 2>&1 | %FileCheck %s --check-prefix=PCM_OUTPUT
|
||||
|
||||
// DOCC_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.docc'
|
||||
// CONSTVALUE_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.swiftconstvalues'
|
||||
// MODULE_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.swiftmodule'
|
||||
// SIB_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.sib'
|
||||
// DEPS_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.d'
|
||||
|
||||
Reference in New Issue
Block a user