Skip to content

Commit c1384f3

Browse files
committed
SIL: Add -disable-subst-sil-function-types flag to work around type lowering bugs
1 parent 01965d2 commit c1384f3

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ namespace swift {
283283
/// Whether to dump debug info for request evaluator cycles.
284284
bool DebugDumpCycles = false;
285285

286+
/// Disable SIL substituted function types.
287+
bool DisableSubstSILFunctionTypes = false;
288+
286289
/// Whether to diagnose an ephemeral to non-ephemeral conversion as an
287290
/// error.
288291
bool DiagnoseInvalidEphemeralnessAsError = false;

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ def enable_experimental_static_assert :
476476
Flag<["-"], "enable-experimental-static-assert">,
477477
HelpText<"Enable experimental #assert">;
478478

479+
def disable_subst_sil_function_types :
480+
Flag<["-"], "disable-subst-sil-function-types">,
481+
HelpText<"Disable substituted function types for SIL type lowering of function values">;
482+
479483
def enable_experimental_named_opaque_types :
480484
Flag<["-"], "enable-experimental-named-opaque-types">,
481485
HelpText<"Enable experimental support for named opaque result types">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
843843
}
844844
}
845845

846+
Opts.DisableSubstSILFunctionTypes =
847+
Args.hasArg(OPT_disable_subst_sil_function_types);
848+
846849
if (auto A = Args.getLastArg(OPT_requirement_machine_EQ)) {
847850
auto value = llvm::StringSwitch<Optional<RequirementMachineMode>>(A->getValue())
848851
.Case("off", RequirementMachineMode::Disabled)

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,9 @@ static CanSILFunctionType getSILFunctionType(
19281928
}
19291929

19301930
bool shouldBuildSubstFunctionType = [&]{
1931+
if (TC.Context.LangOpts.DisableSubstSILFunctionTypes)
1932+
return false;
1933+
19311934
// If there is no genericity in the abstraction pattern we're lowering
19321935
// against, we don't need to introduce substitutions into the lowered
19331936
// type.

0 commit comments

Comments
 (0)