This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Transforms] Inliner: Extra checks for unstructured control flow
ClosedPublic

Authored by springerm on Aug 29 2023, 2:08 AM.

Details

Summary

Do not inline IR with multiple blocks into ops that may not support unstructured control flow.

This fixes #64978.

Depends On: D159078

Diff Detail

Event Timeline

springerm created this revision.Aug 29 2023, 2:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2023, 2:08 AM
springerm requested review of this revision.Aug 29 2023, 2:08 AM

I guess you're lookin into the SingleBlockRegion trait still?

mlir/lib/Transforms/Inliner.cpp
460

.size() is O(N), you can probably try &targetRegion->front() != &targetRegion->back() ?
(I don't know if we have a guarantee that targetRegion is not empty?)

472

I'd guarantee lazy evaluation here:

auto targetSupportsMultipleBlocks = [&]() {
    targetRegion->getParentOp()->getName() ==
        resolvedCall.call->getParentOp()->getName() ||
    isa<FunctionOpInterface>(resolvedCall.call->getParentOp());
};
if (sourceHasMultipleBlocks && !targetSupportsMultipleBlocks())

I guess you're lookin into the SingleBlockRegion trait still?

Yes, I'm waiting for comments on the Discourse post, then will update this revision.

springerm updated this revision to Diff 554297.Aug 29 2023, 6:43 AM
springerm marked 2 inline comments as done.
springerm edited the summary of this revision. (Show Details)

address comments

springerm updated this revision to Diff 554303.Aug 29 2023, 6:49 AM

better variable names

javedabsar accepted this revision.Aug 29 2023, 8:05 AM
This revision is now accepted and ready to land.Aug 29 2023, 8:05 AM