This is an archive of the discontinued LLVM Phabricator instance.

[mlir] LLVM dialect: move ensureDistinctSuccessors out of std->LLVM conversion
ClosedPublic

Authored by ftynse on Mar 4 2020, 8:55 AM.

Details

Summary

MLIR supports terminators that have the same successor block with different
block operands, which cannot be expressed in the LLVM's phi-notation as the
block identifier is used to tell apart the predecessors. This limitation can be
worked around by branching to a new block instead, with this new block
unconditionally branching to the original successor and forwarding the
argument. Until now, this transformation was performed during the conversion
from the Standard to the LLVM dialect. This does not scale well to multiple
dialects targeting the LLVM dialect as all of them would have to be aware of
this limitation and perform the preparatory transformation. Instead, do it as a
separate pass and run it immediately before the translation.

Diff Detail

Event Timeline

ftynse created this revision.Mar 4 2020, 8:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2020, 8:55 AM
ftynse updated this revision to Diff 248207.Mar 4 2020, 9:09 AM

more cmake

rriddle added inline comments.Mar 4 2020, 10:31 AM
mlir/include/mlir/Dialect/LLVMIR/Transforms/Legalize.h
29

Can we give this a better name? Legalize seems general, and doesn't really hint that this is just for exporting to LLVMIR. LegalizeForExport seems slightly better, but I'm sure there is a better suggestion.

I tend to agree with riddle that having a better passname. Maybe "LegalizeForLLVM" ?

mlir/lib/Dialect/LLVMIR/Transforms/CMakeLists.txt
7

PUBLIC here please.

mlir/lib/Target/CMakeLists.txt
12

PUBLIC here please.

This revision is now accepted and ready to land.Mar 6 2020, 1:28 PM
ftynse updated this revision to Diff 250762.Mar 17 2020, 7:13 AM

Rename Legalize -> LegalizeForExport and rebase.

ftynse marked 2 inline comments as done.Mar 17 2020, 7:23 AM
This revision was automatically updated to reflect the committed changes.