llvm-project/mlir/lib/Target/SPIRV/Serialization
Lei Zhang 5e55a20119 [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
2021-12-13 10:42:26 -05:00
..
CMakeLists.txt [MLIR][SPIRV] NFC: Split serialization code among multiple files. 2021-02-08 14:15:31 +01:00
Serialization.cpp [mlir][spirv] Add serialization control to emit symbol name 2021-12-10 19:20:49 -05:00
SerializeOps.cpp [mlir][spirv] Serialize selection with separate header block 2021-12-13 10:42:26 -05:00
Serializer.cpp [mlir][spirv] Fix nested control flow serialization 2021-12-11 14:47:19 -05:00
Serializer.h [mlir][spirv] Fix nested control flow serialization 2021-12-11 14:47:19 -05:00