[mlir] handle nested regions in llvm-legalize-for-export
authorAlex Zinenko <zinenko@google.com>
Tue, 18 Jan 2022 09:16:19 +0000 (10:16 +0100)
committerAlex Zinenko <zinenko@google.com>
Tue, 18 Jan 2022 16:09:14 +0000 (17:09 +0100)
commit1ad48d6de27089d0223543c0b5c33961c08de877
treeaa29a10134be36d304e503906e92dd0e7a6c8653
parent7b1ceee63ea6c0c97d6428ef4ef26deccfcef224
[mlir] handle nested regions in llvm-legalize-for-export

The translation from the MLIR LLVM dialect to LLVM IR includes a mechanism that
ensures the successors of a block to be different blocks in case block
arguments are passed to them since the opposite cannot be expressed in LLVM IR.
This mechanism previously only worked for functions because it was written
prior to the introduction of other region-carrying operations such as the
OpenMP dialect, which also translates directly to LLVM IR. Modify this
mechanism to handle all regions in the module and not only functions.

Reviewed By: wsmoses

Differential Revision: https://reviews.llvm.org/D117548
mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp
mlir/test/Dialect/LLVMIR/legalize-for-export.mlir
mlir/test/Target/LLVMIR/openmp-llvm.mlir