Skip to content

Commit 85b767d

Browse files
authored
Merge pull request #60139 from artemcm/AddConstValueExtractionPathHandling
Add supplementary output path handling for extracted compile-time-known values
2 parents 0f83b65 + b1fee93 commit 85b767d

21 files changed

+171
-0
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ ERROR(error_mode_cannot_emit_symbol_graph,none,
143143
"this mode does not support emitting symbol graph files", ())
144144
ERROR(error_mode_cannot_emit_abi_descriptor,none,
145145
"this mode does not support emitting ABI descriptor", ())
146+
ERROR(error_mode_cannot_emit_const_values,none,
147+
"this mode does not support emitting extracted const values", ())
146148
ERROR(error_mode_cannot_emit_module_semantic_info,none,
147149
"this mode does not support emitting module semantic info", ())
148150
ERROR(cannot_emit_ir_skipping_function_bodies,none,

include/swift/AST/SearchPathOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ class SearchPathOptions {
339339
/// A file containing modules we should perform batch scanning.
340340
std::string BatchScanInputFilePath;
341341

342+
/// A file containing a list of protocols whose conformances require const value extraction.
343+
std::string ConstGatherProtocolListFilePath;
344+
342345
/// Debug path mappings to apply to serialized search paths. These are
343346
/// specified in LLDB from the target.source-map entries.
344347
PathRemapper SearchPathRemapper;

include/swift/Basic/FileTypes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ TYPE("json-dependencies", JSONDependencies, "dependencies.json",
7777
// Complete feature information for the given Swift compiler.
7878
TYPE("json-features", JSONFeatures, "features.json", "")
7979

80+
// Gathered compile-time-known value information for the given Swift input file as JSON.
81+
TYPE("const-values", ConstValues, "swiftconstvalues", "")
8082

8183
TYPE("index-data", IndexData, "", "")
8284
TYPE("index-unit-output-path", IndexUnitOutputPath, "", "")

include/swift/Basic/SupplementaryOutputPaths.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ struct SupplementaryOutputPaths {
147147
/// The output path to generate ABI baseline.
148148
std::string ABIDescriptorOutputPath;
149149

150+
/// The output path for extracted compile-time-known value information
151+
std::string ConstValuesOutputPath;
152+
150153
/// The output path of Swift semantic info for this module.
151154
std::string ModuleSemanticInfoOutputPath;
152155

@@ -188,6 +191,8 @@ struct SupplementaryOutputPaths {
188191
fn(ModuleSummaryOutputPath);
189192
if (!ABIDescriptorOutputPath.empty())
190193
fn(ABIDescriptorOutputPath);
194+
if (!ConstValuesOutputPath.empty())
195+
fn(ConstValuesOutputPath);
191196
if (!YAMLOptRecordPath.empty())
192197
fn(YAMLOptRecordPath);
193198
if (!BitstreamOptRecordPath.empty())
@@ -204,6 +209,7 @@ struct SupplementaryOutputPaths {
204209
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
205210
ModuleSourceInfoOutputPath.empty() &&
206211
ABIDescriptorOutputPath.empty() &&
212+
ConstValuesOutputPath.empty() &&
207213
ModuleSemanticInfoOutputPath.empty() && YAMLOptRecordPath.empty() &&
208214
BitstreamOptRecordPath.empty();
209215
}

include/swift/Frontend/Frontend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class CompilerInvocation {
396396
std::string getModuleOutputPathForAtMostOnePrimary() const;
397397
std::string
398398
getReferenceDependenciesFilePathForPrimary(StringRef filename) const;
399+
std::string getConstValuesFilePathForPrimary(StringRef filename) const;
399400
std::string getSerializedDiagnosticsPathForAtMostOnePrimary() const;
400401

401402
/// TBDPath only makes sense in whole module compilation mode,

include/swift/Frontend/FrontendInputsAndOutputs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class FrontendInputsAndOutputs {
257257
bool hasModuleInterfaceOutputPath() const;
258258
bool hasPrivateModuleInterfaceOutputPath() const;
259259
bool hasABIDescriptorOutputPath() const;
260+
bool hasConstValuesOutputPath() const;
260261
bool hasModuleSemanticInfoOutputPath() const;
261262
bool hasModuleSummaryOutputPath() const;
262263
bool hasTBDPath() const;

include/swift/Frontend/FrontendOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ class FrontendOptions {
472472
static bool canActionEmitModuleSummary(ActionType);
473473
static bool canActionEmitInterface(ActionType);
474474
static bool canActionEmitABIDescriptor(ActionType);
475+
static bool canActionEmitConstValues(ActionType);
475476
static bool canActionEmitModuleSemanticInfo(ActionType);
476477

477478
public:

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ def explicit_swift_module_map
192192
: Separate<["-"], "explicit-swift-module-map-file">, MetaVarName<"<path>">,
193193
HelpText<"Specify a JSON file containing information of explicit Swift modules">;
194194

195+
def const_gather_protocols_file
196+
: Separate<["-"], "const-gather-protocols-file">, MetaVarName<"<path>">,
197+
HelpText<"Specify a list of protocols for extraction of conformances' const values'">;
198+
195199
def placeholder_dependency_module_map
196200
: Separate<["-"], "placeholder-dependency-module-map-file">, MetaVarName<"<path>">,
197201
HelpText<"Specify a JSON file containing information of external Swift module dependencies">;

include/swift/Option/Options.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@ def emit_parseable_module_interface_path :
524524
Flags<[FrontendOption, NoInteractiveOption, HelpHidden, ArgumentIsPath,
525525
SupplementaryOutput]>;
526526

527+
def emit_const_values :
528+
Flag<["-"], "emit-const-values">,
529+
Flags<[NoInteractiveOption, SupplementaryOutput]>;
530+
def emit_const_values_path : Separate<["-"], "emit-const-values-path">,
531+
Flags<[FrontendOption, NoInteractiveOption, ArgumentIsPath,
532+
SupplementaryOutput]>,
533+
MetaVarName<"<path>">, HelpText<"Emit the extracted compile-time known values to <path>">;
534+
527535
def emit_objc_header : Flag<["-"], "emit-objc-header">,
528536
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput]>,
529537
HelpText<"Emit an Objective-C header file">;

lib/Basic/FileTypes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ bool file_types::isTextual(ID Id) {
8686
case file_types::TY_JSONDependencies:
8787
case file_types::TY_JSONFeatures:
8888
case file_types::TY_SwiftABIDescriptor:
89+
case file_types::TY_ConstValues:
8990
return true;
9091
case file_types::TY_Image:
9192
case file_types::TY_Object:
@@ -160,6 +161,7 @@ bool file_types::isAfterLLVM(ID Id) {
160161
case file_types::TY_JSONFeatures:
161162
case file_types::TY_IndexUnitOutputPath:
162163
case file_types::TY_SwiftABIDescriptor:
164+
case file_types::TY_ConstValues:
163165
return false;
164166
case file_types::TY_INVALID:
165167
llvm_unreachable("Invalid type ID.");
@@ -212,6 +214,7 @@ bool file_types::isPartOfSwiftCompilation(ID Id) {
212214
case file_types::TY_JSONFeatures:
213215
case file_types::TY_IndexUnitOutputPath:
214216
case file_types::TY_SwiftABIDescriptor:
217+
case file_types::TY_ConstValues:
215218
return false;
216219
case file_types::TY_INVALID:
217220
llvm_unreachable("Invalid type ID.");

0 commit comments

Comments
 (0)