[all-commits] [llvm/llvm-project] af562f: Splits cleanup block lowered by AsyncToAsyncRuntim...

Yunlong Liu via All-commits all-commits at lists.llvm.org
Tue Sep 12 11:42:30 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: af562fd27f65fa88b324c4f51a39439f109aeef9
      https://github.com/llvm/llvm-project/commit/af562fd27f65fa88b324c4f51a39439f109aeef9
  Author: Yunlong Liu <yliu120 at users.noreply.github.com>
  Date:   2023-09-12 (Tue, 12 Sep 2023)

  Changed paths:
    M mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
    M mlir/test/Dialect/Async/async-to-async-runtime.mlir

  Log Message:
  -----------
  Splits cleanup block lowered by AsyncToAsyncRuntime. (#66123)

Splits the cleanup block lowered from AsyncToAsyncRuntime.

The incentive of this change is to clarify the CFG branched by
`async.coro.suspend`.

The `async.coro.suspend` op branches into 3 blocks, depending on the
state of the coroutine:
1) suspend
2) resume
3) cleanup

The behavior before this change is that after the coroutine is resumed
and completed, it will jump to a shared cleanup block for destroying the
states of coroutines. The CFG looks like the following,

Entry block
        |                    \
   resume             |
        |                    |
            Cleanup
                   |
                End

This CFG can potentially be problematic, because the `Cleanup` block is
a shared block and it is not dominated by `resume`. For instance, if
some pass wants to add some specific cleanup mechanism to resume, it can
be confused and add them to the shared `Cleanup`, which leads to the
"operand not dominate its use" error because of the existence of the
other "Entry->cleanup" path.

After this change, the CFG will look like the following,

The overall structure of the lowered CFG can be the following,

  Entry (calling async.coro.suspend)
       |                    \
  Resume           Destroy (duplicate of Cleanup)
       |                     |
  Cleanup             |
       |                    /
     End (ends the corontine)

In this case, the Cleanup block tied to the Resume block will be
isolated from the other path and it is strictly dominated by "Resume".




More information about the All-commits mailing list