[Function builders] Add one-way constraints when applying function builders

When we transform each expression or statement in a function builder,
introduce a one-way constraint so that type information does not flow
backwards from the context into that statement or expression. This
more closely mimics the behavior of normal code, where type inference
is per-statement, flowing from top to bottom.

This also allows us to isolate different expressions and statements
within a closure that's passed into a function builder parameter,
reducing the search space and (hopefully) improving compile times for
large function builder closures.

For now, put this functionality behind the compiler flag
`-enable-function-builder-one-way-constraints` for testing purposes;
we still have both optimization and correctness work to do to turn
this on by default.
This commit is contained in:
Doug Gregor
2019-08-02 13:22:17 -07:00
parent 3c69f6a305
commit be73a9d641
7 changed files with 102 additions and 7 deletions

View File

@@ -440,6 +440,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
if (Args.getLastArg(OPT_solver_disable_shrink))
Opts.SolverDisableShrink = true;
if (Args.getLastArg(OPT_enable_function_builder_one_way_constraints))
Opts.FunctionBuilderOneWayConstraints = true;
if (const Arg *A = Args.getLastArg(OPT_value_recursion_threshold)) {
unsigned threshold;