Skip to content

MLIR verifier does not reject mutually recursive programs. #8

@AiredaleDev

Description

@AiredaleDev

In order to lower to OpenQASM 3, which is most representative of real hardware today, we need to guarantee that all QWERTY functions (at least excluding classical control flow) will be inlined into straightline code. While the language itself does not offer a way to construct such programs, the MLIR verifier does not reject all IR that we know that blocks inlining:

module {
  qwerty.func @kernel_0[]() irrev-> !qwerty<bitbundle[1]> {
    %0 = qwerty.qbprep Z<MINUS>[1] : () -> !qwerty<qbundle[1]>
    %1 = qwerty.call @tweedledee_1(%0) : (!qwerty<qbundle[1]>) -> !qwerty<bitbundle[1]>
    qwerty.return %1 : !qwerty<bitbundle[1]>
  }
  qwerty.func @tweedledee_1[](%arg0: !qwerty<qbundle[1]>) irrev-> !qwerty<bitbundle[1]> {
    %0 = qwerty.call @tweedledum_2(%arg0) : (!qwerty<qbundle[1]>) -> !qwerty<bitbundle[1]>
    qwerty.return %0 : !qwerty<bitbundle[1]>
  }
  qwerty.func @tweedledum_2[](%arg0: !qwerty<qbundle[1]>) irrev-> !qwerty<bitbundle[1]> {
    %0 = qwerty.call @tweedledee_1(%arg0) : (!qwerty<qbundle[1]>) -> !qwerty<bitbundle[1]>
    qwerty.return %0 : !qwerty<bitbundle[1]>
  }
}

The verifier admits this IR. When run with the inline pass, both calls to tweedledee_1 are replaced with calls to tweedledum_2. Additionally, the symbol_dce pass does nothing after this despite tweedledee_1 being dead code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions