This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add a utility function to make a region isolated from above.
ClosedPublic

Authored by mravishankar on Apr 18 2023, 11:02 PM.

Details

Summary

The utility functions takes a region and makes it isolated from above
by appending to the entry block arguments that represent the captured
values and replacing all uses of the captured values within the region
with the newly added arguments. The captures values are returned.

The utility function also takes an optional callback that allows
cloning operations that define the captured values into the region
during the process of making it isolated from above. The cloned value
is no longer a captured values. The operands of the operation are then
captured values. This is done transitively allow cloning of a DAG of
operations into the region based on the callback.

Diff Detail

Event Timeline

mravishankar created this revision.Apr 18 2023, 11:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2023, 11:02 PM

Add lit tests.

mravishankar published this revision for review.Apr 19 2023, 11:54 AM
jpienaar accepted this revision.Apr 19 2023, 9:23 PM

Seems good and useful, thanks

mlir/lib/Transforms/Utils/RegionUtils.cpp
126

Could you add comment describing why this is needed?

This revision is now accepted and ready to land.Apr 19 2023, 9:23 PM
mravishankar marked an inline comment as done.Apr 20 2023, 10:13 AM

I forgot to submit my comments... just a minor comment, overall LG.

mlir/lib/Transforms/Utils/RegionUtils.cpp
88

The usage of it looks like a queue. We don't use push_front or pop_back methods. Maybe we can use queue instead?