This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferize] Add filterFn option to BufferResultsToOutParams
ClosedPublic

Authored by cota on Nov 2 2022, 9:05 AM.

Details

Summary

This allows users to restrict the transformation to a
subset of the functions in a module.

For example, a user might want to apply the transformation to
a module's entry point, but not to the calls in the module
because those calls might refer to external C functions outside
of their control.

Diff Detail

Event Timeline

cota created this revision.Nov 2 2022, 9:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2022, 9:05 AM
cota requested review of this revision.Nov 2 2022, 9:05 AM
nicolasvasilache requested changes to this revision.Nov 2 2022, 9:28 AM

strong -1 to reintroducing markers, we've clearly seen their limits.

Since the usage is trivial here, we can use the "deny" mechanism with a lambda to make it dynamic (like dynamic legality).

This revision now requires changes to proceed.Nov 2 2022, 9:28 AM

(You can add the lambda to BufferResultsToOutParamsOptions. E.g., it returns true for functions that should be processed. By default it can return true for all functions.)

cota added a comment.Nov 2 2022, 10:02 AM

+1 for the lambda.
Is it OK to keep the markers for testing only though? Otherwise I don't know how I'd test this.
Thanks!

Is it OK to keep the markers for testing only though? Otherwise I don't know how I'd test this.

Ideally, that should be a separate test pass then. But IMO it would be OK to go without a test for this, the extra boilerplate is not worth it.

(You can add the lambda to BufferResultsToOutParamsOptions. E.g., it returns true for functions that should be processed. By default it can return true for all functions.)

I was thinking to add the lambda as an optional parameter to the deny mechanism.
I wouldn't add an extra one-off with a default for a specific op (if possible)

I see what you meant. This is not the bufferization pass. We don't have a deny mechanism (or any options) yet.

cota updated this revision to Diff 472767.Nov 2 2022, 2:25 PM

Remove the marker; add filterFn lambda.

Please take another look! Thanks.

cota retitled this revision from [mlir][bufferize] Add restrictToMarkedFunctions option to BufferResultsToOutParams to [mlir][bufferize] Add filterFn option to BufferResultsToOutParams.Nov 2 2022, 2:26 PM
cota edited the summary of this revision. (Show Details)

I also removed the tests as suggested by @springerm.

springerm accepted this revision.Nov 3 2022, 2:05 AM
springerm added inline comments.
mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp
135–137

nit: trivial braces can be removed

188–190

nit: trivial braces

cota updated this revision to Diff 472941.Nov 3 2022, 7:49 AM
cota marked 2 inline comments as done.

if (foo)

bar;
cota added a comment.Nov 3 2022, 7:50 AM

Resolve nits.

nicolasvasilache accepted this revision.Nov 3 2022, 8:40 AM

I see what you meant. This is not the bufferization pass. We don't have a deny mechanism (or any options) yet.

Ah ok, nm then, this then looks fine.

This revision is now accepted and ready to land.Nov 3 2022, 8:40 AM