llvm-project/mlir/unittests
Alex Zinenko 8b58ab8ccd [mlir] Factor type reconciliation out of Standard-to-LLVM conversion
Conversion to the LLVM dialect is being refactored to be more progressive and
is now performed as a series of independent passes converting different
dialects. These passes may produce `unrealized_conversion_cast` operations that
represent pending conversions between built-in and LLVM dialect types.
Historically, a more monolithic Standard-to-LLVM conversion pass did not need
these casts as all operations were converted in one shot. Previous refactorings
have led to the requirement of running the Standard-to-LLVM conversion pass to
clean up `unrealized_conversion_cast`s even though the IR had no standard
operations in it. The pass must have been also run the last among all to-LLVM
passes, in contradiction with the partial conversion logic. Additionally, the
way it was set up could produce invalid operations by removing casts between
LLVM and built-in types even when the consumer did not accept the uncasted
type, or could lead to cryptic conversion errors (recursive application of the
rewrite pattern on `unrealized_conversion_cast` as a means to indicate failure
to eliminate casts).

In fact, the need to eliminate A->B->A `unrealized_conversion_cast`s is not
specific to to-LLVM conversions and can be factored out into a separate type
reconciliation pass, which is achieved in this commit. While the cast operation
itself has a folder pattern, it is insufficient in most conversion passes as
the folder only applies to the second cast. Without complex legality setup in
the conversion target, the conversion infra will either consider the cast
operations valid and not fold them (a separate canonicalization would be
necessary to trigger the folding), or consider the first cast invalid upon
generation and stop with error. The pattern provided by the reconciliation pass
applies to the first cast operation instead. Furthermore, having a separate
pass makes it clear when `unrealized_conversion_cast`s could not have been
eliminated since it is the only reason why this pass can fail.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D109507
2021-09-09 16:51:24 +02:00
..
Analysis [MLIR] FlatAffineConstraints: Refactored computation of explicit representation for identifiers 2021-09-08 20:24:46 +05:30
Dialect [mlir][sparse] add support for std unary operations 2021-07-13 14:51:13 -07:00
ExecutionEngine [mlir] Factor type reconciliation out of Standard-to-LLVM conversion 2021-09-09 16:51:24 +02:00
IR [MLIR] Move TestDialect to ::test namespace 2021-08-14 13:24:41 -07:00
Interfaces [mlir] Enable specifying querying function in ValueShapeRange 2021-08-10 11:44:20 -07:00
Pass Defend early against operation created without a registered dialect 2021-07-15 03:52:32 +00:00
Rewrite [mlir][Pattern] Add better support for using interfaces/traits to match root operations in rewrite patterns 2021-03-23 14:05:33 -07:00
Support [mlir][StorageUniquer] Properly call the destructor on non-trivially destructible storage instances 2021-03-11 11:35:32 -08:00
TableGen [mlir][ODS] Fix copy ctor for generate Pass classes 2021-06-21 14:07:31 +03:00
CMakeLists.txt [mlir] Remove SDBM 2021-06-29 14:46:26 +02:00