Skip to content

Commit bb1d1ae

Browse files
committed
SIL: Add -disable-subst-sil-function-types flag to work around type lowering bugs
1 parent 3fbb52c commit bb1d1ae

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
@@ -464,6 +464,10 @@ def enable_experimental_static_assert :
464464
Flag<["-"], "enable-experimental-static-assert">,
465465
HelpText<"Enable experimental #assert">;
466466

467+
def disable_subst_sil_function_types :
468+
Flag<["-"], "disable-subst-sil-function-types">,
469+
HelpText<"Disable substituted function types for SIL type lowering of function values">;
470+
467471
def enable_experimental_named_opaque_types :
468472
Flag<["-"], "enable-experimental-named-opaque-types">,
469473
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
@@ -838,6 +838,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
838838
}
839839
}
840840

841+
Opts.DisableSubstSILFunctionTypes =
842+
Args.hasArg(OPT_disable_subst_sil_function_types);
843+
841844
if (auto A = Args.getLastArg(OPT_requirement_machine_EQ)) {
842845
auto value = llvm::StringSwitch<Optional<RequirementMachineMode>>(A->getValue())
843846
.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)