Skip to content

Commit e45b054

Browse files
committed
[IRGen] Added gate for metadata prespecialization.
The new frontend flag -prespecialize-generic-metadata must be passed in order for generic metadata to be specialized statically. rdar://problem/56984885
1 parent 525e256 commit e45b054

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ class IRGenOptions {
190190
/// Passing this flag completely disables this behavior.
191191
unsigned DisableLegacyTypeInfo : 1;
192192

193+
/// Create metadata specializations for generic types at statically known type
194+
/// arguments.
195+
unsigned PrespecializeGenericMetadata : 1;
196+
193197
/// The path to load legacy type layouts from.
194198
StringRef ReadLegacyTypeInfoPath;
195199

@@ -255,8 +259,9 @@ class IRGenOptions {
255259
EnableAnonymousContextMangledNames(false), ForcePublicLinkage(false),
256260
LazyInitializeClassMetadata(false),
257261
LazyInitializeProtocolConformances(false), DisableLegacyTypeInfo(false),
258-
UseIncrementalLLVMCodeGen(true), UseSwiftCall(false),
259-
GenerateProfile(false), EnableDynamicReplacementChaining(false),
262+
PrespecializeGenericMetadata(false), UseIncrementalLLVMCodeGen(true),
263+
UseSwiftCall(false), GenerateProfile(false),
264+
EnableDynamicReplacementChaining(false),
260265
DisableRoundTripDebugTypes(false), DisableDebuggerShadowCopies(false),
261266
CmdArgs(), SanitizeCoverage(llvm::SanitizerCoverageOptions()),
262267
TypeInfoFilter(TypeInfoDumpFilter::All) {}

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,10 @@ def disable_verify_exclusivity : Flag<["-"], "disable-verify-exclusivity">,
644644
def disable_legacy_type_info : Flag<["-"], "disable-legacy-type-info">,
645645
HelpText<"Completely disable legacy type layout">;
646646

647+
def prespecialize_generic_metadata : Flag<["-"], "prespecialize-generic-metadata">,
648+
HelpText<"Statically specialize metadata for generic types at types that "
649+
"are known to be used in source.">;
650+
647651
def read_legacy_type_info_path_EQ : Joined<["-"], "read-legacy-type-info-path=">,
648652
HelpText<"Read legacy type layout from the given path instead of default path">;
649653

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
12491249
Opts.DisableLegacyTypeInfo = true;
12501250
}
12511251

1252+
if (Args.hasArg(OPT_prespecialize_generic_metadata)) {
1253+
Opts.PrespecializeGenericMetadata = true;
1254+
}
1255+
12521256
if (const Arg *A = Args.getLastArg(OPT_read_legacy_type_info_path_EQ)) {
12531257
Opts.ReadLegacyTypeInfoPath = A->getValue();
12541258
}

0 commit comments

Comments
 (0)