Skip to content

Commit 3c29c5e

Browse files
committed
Add a new flag -enable-recompilation-to-ossa-module
1 parent 7a81fcc commit 3c29c5e

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

include/swift/AST/SILOptions.h

+4
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ class SILOptions {
188188
/// If this is disabled we do not serialize in OSSA form when optimizing.
189189
bool EnableOSSAModules = false;
190190

191+
/// Allow recompilation of a non-OSSA module to an OSSA module when imported
192+
/// from another OSSA module.
193+
bool EnableRecompilationToOSSAModule = false;
194+
191195
/// If set to true, compile with the SIL Opaque Values enabled.
192196
bool EnableSILOpaqueValues = false;
193197

include/swift/Option/FrontendOptions.td

+3
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,9 @@ let Flags = [FrontendOption, NoDriverOption, HelpHidden, ModuleInterfaceOptionIg
12261226
"when optimizing ownership will be lowered before serializing SIL">;
12271227
}
12281228

1229+
def enable_recompilation_to_ossa_module : Flag<["-"], "enable-recompilation-to-ossa-module">,
1230+
HelpText<"Allow recompilation of a non-OSSA module to an OSSA module when imported from another OSSA module">;
1231+
12291232
def enable_sil_opaque_values : Flag<["-"], "enable-sil-opaque-values">,
12301233
HelpText<"Enable SIL Opaque Values">;
12311234

lib/Frontend/CompilerInvocation.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2697,6 +2697,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
26972697

26982698
Opts.EnableARCOptimizations &= !Args.hasArg(OPT_disable_arc_opts);
26992699
Opts.EnableOSSAModules |= Args.hasArg(OPT_enable_ossa_modules);
2700+
Opts.EnableRecompilationToOSSAModule |=
2701+
Args.hasArg(OPT_enable_recompilation_to_ossa_module);
27002702
Opts.EnableOSSAOptimizations &= !Args.hasArg(OPT_disable_ossa_opts);
27012703
Opts.EnableSILOpaqueValues = Args.hasFlag(
27022704
OPT_enable_sil_opaque_values, OPT_disable_sil_opaque_values, false);

lib/Serialization/SerializedModuleLoader.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,8 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
11901190
moduleBufferID);
11911191
break;
11921192
case serialization::Status::NotInOSSA:
1193-
// Diagnose only when explicit build modules is enabled
1194-
if (Ctx.SerializationOpts.ExplicitModuleBuild) {
1193+
if (Ctx.SerializationOpts.ExplicitModuleBuild ||
1194+
!Ctx.SILOpts.EnableRecompilationToOSSAModule) {
11951195
Ctx.Diags.diagnose(diagLoc,
11961196
diag::serialization_non_ossa_module_incompatible,
11971197
ModuleName);

0 commit comments

Comments
 (0)