This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Use-after-free checker for the Transform dialect
ClosedPublic

Authored by ftynse on May 25 2022, 7:39 AM.

Details

Summary

The Transform dialect uses the side effect modeling mechanism to record the
effects of the transform ops on the mapping between Transform IR values and
Payload IR ops. Introduce a checker pass that warns if a Transform IR value is
used after it has been freed (consumed). This pass is mostly intended as a
debugging aid in addition to the verification/assertion mechanisms in the
transform interpreter. It reports all potential use-after-free situations.
The implementation makes a series of simplifying assumptions to be simple and
conservative. A more advanced implementation would rely on the data flow-like
analysis associated with a side-effect resource rather than a value, which is
currently not supported by the analysis infrastructure.

Diff Detail

Event Timeline

ftynse created this revision.May 25 2022, 7:39 AM
ftynse requested review of this revision.May 25 2022, 7:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2022, 7:39 AM
springerm accepted this revision.May 25 2022, 10:43 AM
springerm added inline comments.
mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
52–56

I've seen code that simply uses DeclareOpInterfaceMethods<RegionBranchOpInterface>, so maybe it even works without explicitly listing all interface methods.

mlir/include/mlir/Dialect/Transform/Transforms/Passes.td
19

typo

30

typo

mlir/lib/Dialect/Transform/IR/TransformOps.cpp
297

should this be operand_begin?

318

is this needed?

This revision is now accepted and ready to land.May 25 2022, 10:43 AM
ftynse marked 5 inline comments as done.May 26 2022, 3:26 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
52–56

This makes the generator emit declarations for methods that have the default implementation, also signaling the reader that these methods will be reimplemented. Without listing them, no declaration will be emitted and the code will fail to compile.

mlir/lib/Dialect/Transform/IR/TransformOps.cpp
297

No, we want to return an empty range.

318

Yes, otherwise we may get an unused argument warning.

ftynse updated this revision to Diff 432230.May 26 2022, 3:27 AM
ftynse marked 3 inline comments as done.

Review.

This revision was landed with ongoing or failed builds.May 26 2022, 3:28 AM
This revision was automatically updated to reflect the committed changes.