This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Add a ComprehensiveModuleBufferizePass and support for CallOp analysis(9/n)
ClosedPublic

Authored by nicolasvasilache on Jun 24 2021, 7:26 AM.

Details

Summary

This revision adds the minimal plumbing to create a simple ComprehensiveModuleBufferizePass that can behave conservatively in the presence of CallOps.

A topological sort of caller/callee is performed and, if the call-graph is cycle-free, analysis can proceed.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Jun 24 2021, 7:26 AM
ftynse added inline comments.Jun 28 2021, 3:41 AM
mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
412
1902

Should we bail out entirely if the callable is not a FuncOp?

1910

Nit: I got confused by the combination of the name (callCounter) and behavior here. It seems to count calls to distinct functions, not all calls, i.e. a repeated call to the same function won't be counted twice.

1974–1975

I don't think we reset the IR on module failure, and the code just above this modifies function argument attributes.

nicolasvasilache marked 4 inline comments as done.Jun 29 2021, 8:39 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
1910

spelled it out a little longer and dropped the doubly-nested walk.

1974–1975

Comment was stale, dropped it.

Re signalPassFailure, the doc says:

/// Signal that some invariant was broken when running. The IR is allowed to
/// be in an invalid state.
void signalPassFailure() { getPassState().irAndPassFailed.setInt(true); }

AFAIK no pass that signal failure tries to put the IR back in a valid state.

Added a post-pass cleanup for FuncOp bbargs indeed.

nicolasvasilache marked 2 inline comments as done.

Address comments.

ftynse accepted this revision.Jun 29 2021, 8:41 AM
ftynse added inline comments.
mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
1974–1975

Yeah, I was just making sure that nobody will expect the IR to be rolled back.

This revision is now accepted and ready to land.Jun 29 2021, 8:41 AM

Properly return.

This revision was landed with ongoing or failed builds.Jun 29 2021, 12:20 PM
This revision was automatically updated to reflect the committed changes.