Skip to content

Commit 8959d4c

Browse files
committed
[Frontend] Added option to bypass resilience.
This functionality was added awhile back to support the debugger. Provide a flag for use by other cliients.
1 parent aad2b6e commit 8959d4c

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,10 @@ namespace swift {
576576
/// All block list configuration files to be honored in this compilation.
577577
std::vector<std::string> BlocklistConfigFilePaths;
578578

579+
/// Whether to ignore checks that a module is resilient during
580+
/// type-checking, SIL verification, and IR emission,
581+
bool BypassResilienceChecks = false;
582+
579583
bool isConcurrencyModelTaskToThread() const {
580584
return ActiveConcurrencyModel == ConcurrencyModel::TaskToThread;
581585
}

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,10 @@ def disable_swift3_objc_inference :
638638
def enable_implicit_dynamic : Flag<["-"], "enable-implicit-dynamic">,
639639
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
640640
HelpText<"Add 'dynamic' to all declarations">;
641+
642+
def bypass_resilience : Flag<["-"], "bypass-resilience-checks">,
643+
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
644+
HelpText<"Ignore all checks for module resilience.">;
641645

642646
def enable_experimental_opaque_type_erasure : Flag<["-"], "enable-experimental-opaque-type-erasure">,
643647
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,

lib/DriverTool/sil_opt_main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ struct SILOptOptions {
491491
"enable-copy-propagation",
492492
llvm::cl::desc("Whether to run the copy propagation pass: "
493493
"'true', 'false', or 'requested-passes-only'."));
494+
495+
llvm::cl::opt<bool> BypassResilienceChecks = llvm::cl::opt<bool>(
496+
"bypass-resilience-checks",
497+
llvm::cl::desc("Ignore all checks for module resilience."));
494498
};
495499

496500
/// Regular expression corresponding to the value given in one of the
@@ -603,6 +607,8 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
603607
Invocation.getLangOptions().Features.insert(
604608
Feature::OldOwnershipOperatorSpellings);
605609
}
610+
Invocation.getLangOptions().BypassResilienceChecks =
611+
options.BypassResilienceChecks;
606612
for (auto &featureName : options.ExperimentalFeatures) {
607613
if (auto feature = getExperimentalFeature(featureName)) {
608614
Invocation.getLangOptions().Features.insert(*feature);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
13021302
.Case("task-to-thread", ConcurrencyModel::TaskToThread)
13031303
.Default(ConcurrencyModel::Standard);
13041304
}
1305+
Opts.BypassResilienceChecks |= Args.hasArg(OPT_bypass_resilience);
13051306

13061307
return HadError || UnsupportedOS || UnsupportedArch;
13071308
}

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,8 @@ ModuleDecl *CompilerInstance::getMainModule() const {
12901290
MainModule->setPrivateImportsEnabled();
12911291
if (Invocation.getFrontendOptions().EnableImplicitDynamic)
12921292
MainModule->setImplicitDynamicEnabled();
1293+
if (Invocation.getLangOptions().BypassResilienceChecks)
1294+
MainModule->setBypassResilience();
12931295
if (!Invocation.getFrontendOptions().ModuleABIName.empty()) {
12941296
MainModule->setABIName(getASTContext().getIdentifier(
12951297
Invocation.getFrontendOptions().ModuleABIName));

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,8 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
849849
for (auto name: loadedModuleFile->getAllowableClientNames()) {
850850
M.addAllowableClientName(Ctx.getIdentifier(name));
851851
}
852+
if (Ctx.LangOpts.BypassResilienceChecks)
853+
M.setBypassResilience();
852854
auto diagLocOrInvalid = diagLoc.value_or(SourceLoc());
853855
loadInfo.status = loadedModuleFile->associateWithFileContext(
854856
fileUnit, diagLocOrInvalid, Ctx.LangOpts.AllowModuleWithCompilerErrors);

0 commit comments

Comments
 (0)