[all-commits] [llvm/llvm-project] 5e55a2: [mlir][spirv] Serialize selection with separate he...

Lei Zhang via All-commits all-commits at lists.llvm.org
Mon Dec 13 07:42:54 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5e55a20119a31c19dd90a2e03329d21c291ea362
      https://github.com/llvm/llvm-project/commit/5e55a20119a31c19dd90a2e03329d21c291ea362
  Author: Lei Zhang <antiagainst at google.com>
  Date:   2021-12-13 (Mon, 13 Dec 2021)

  Changed paths:
    M mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
    M mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
    M mlir/test/Target/SPIRV/loop.mlir
    M mlir/test/Target/SPIRV/selection.mlir

  Log Message:
  -----------
  [mlir][spirv] Serialize selection with separate header block

The previous "optimization" that tries to reuse existing block for
selection header block can be problematic for deserialization
because it effectively pulls in previous ops in the selection op's
enclosing block into the selection op's header. When deserializing,
those ops will be placed in the selection op's region. If any of
the previous ops has usage after the section op, it will break. That
is, the following IR cannot round trip:

```mlir
^bb:
  %def = ...
  spv.mlir.selection { ... }
  %use = spv.SomeOp %def
```

This commit removes the "optimization" to always create new blocks
for the selection header.

Along the way, also made error reporting better in deserialization
by turning asserts into proper errors and add check of uses outside
of sinked structured control flow region blocks.

Reviewed By: Hardcode84

Differential Revision: https://reviews.llvm.org/D115582




More information about the All-commits mailing list