Skip to content

-j --legacy-codegen: give each closure a name unique in the program, so that a program with closures can use the parallel check #4012

Backlog

Description

@bajpainaman

vxc -j N --legacy-codegen (PR #4006, for #3139) cannot compile a program that has a closure on the parallel path. It sends the program to a normal compile and prints a note on stderr.

The reason: the checker names each closure with a counter (Closure_1, Closure_2, ...), and that name is in the MLIR. A normal compile keeps one counter for the whole program. A parallel check starts the counter again in each function. So two functions can both make a Closure_1. Without the rule in #4006, the second closure runs the body of the first one, and the closure fixture of #4006 prints 12 instead of 6.

Done when:

  • The parallel check gives each closure a name that no other function of the program uses. It should not depend on the thread count. For example, prefix the name with the name of the function, or number the closures after all checks end.
  • -j N --legacy-codegen on a program with closures takes the parallel path. Its bytes match the normal --legacy-codegen compile at -j 1, -j 2 and -j 8.
  • The rule made_closure in check_modules_for_ast_codegen (from driver: -j with --legacy-codegen checks in parallel, then the AST code generator makes the MLIR #4006) and its stderr note are removed.

The names that ?, vec! and tasks get from counters do not need this. They stay in one function, and a normal compile also starts them again in each function.

Found in #4006.

Activity

  1. added
    codegen
    core-lang
    enhancement
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegencore-langenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions