This is an archive of the discontinued LLVM Phabricator instance.

[mlir][CFGToSCF] Add interface changes for downstream projects
ClosedPublic

Authored by zero9178 on Aug 15 2023, 6:58 AM.

Details

Summary

This is a follow-up to https://reviews.llvm.org/D156889

Downstream projects may have more complicated ops than the control flow ops upstream and therefore need a more powerful interface to support the lifting process. Use cases include the propagation of (inherent) metadata that was previously on the control flow ops and now needs to be lifted to structured control flow ops.
Since the lifting process is inherently non-local in respect to the function-body, we require stronger guarantees from the interface.

This patch therefore makes two changes to the interface:

  • Passes the terminator that is being replaced to createStructuredBranchRegionTerminatorOp
  • Adds as precondition to createCFGSwitchOp that its predecessors are already correctly established

Asserts have been added to verify these were it makes sense and to correctly state intent. I have not added tests purely because testing preconditions like these is not really feasible (and incredibly specific).

Diff Detail

Event Timeline

zero9178 created this revision.Aug 15 2023, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2023, 6:58 AM
zero9178 requested review of this revision.Aug 15 2023, 6:58 AM
zero9178 updated this revision to Diff 550317.Aug 15 2023, 6:59 AM
zero9178 retitled this revision from [mlir][CFGToSCF] Add interface changes for downstream projects Markus Böck 6 minutes ago to [mlir][CFGToSCF] Add interface changes for downstream projects.

rebase

definelicht accepted this revision.Aug 15 2023, 7:13 AM

LGTM

mlir/lib/Transforms/Utils/CFGToSCF.cpp
514
574
This revision is now accepted and ready to land.Aug 15 2023, 7:13 AM
This revision was automatically updated to reflect the committed changes.
zero9178 marked 2 inline comments as done.