Skip to content

x/tools/internal/refactor/inline: good starter projects #63352

Open
@adonovan

Description

@adonovan

Below is a list of starter projects for anyone who wants to get their hands dirty in the inliner logic. Before starting work on any item, please fork it off into a separate issue, briefly stating the approach you plan to take.

        //    x, y     = f()
        //    x, y    := f()
        //    var x, y = f()
  • use binding decls even with the literalization strategy: it's easier and more natural to read func() { var param=arg; ... } () than func(param) { ... } (arg). (Beware: binding decls cover params and named result vars; they may need to be teased apart.)
  • clean-up (?): unify pure, duplicable, and effects into a single pass.
  • use callee's FileSet (calleeFset) to format the new node (res.new), as it is mostly callee code. This should reduce comment loss. (Beware: it seems to introduce spurious newlines. Why?)

See also:

More challenging projects:

  • Translate if f(); cond { ... } to { fbody; if cond { ... } } when the inlining of f() is not a simple expression.- [ ] Add a control flow analysis that is more precise than the current "single assignment" predicate. Currently, a binding declaration is required if an argument is a variable that is not "single assignment". But if all the assignments can be proved to occur before or after the call (but not during it using lambdas) then a binding declaration may not be needed.
  • Add an alias analysis so that effects on memory by the callee can be localized to particular variables, allowing writes to commute with reads if they cannot alias.
  • Better handling of spread calls (f(g()) where g returns >1 result).

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.RefactoringIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions