This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Move casting calls from methods to function calls
ClosedPublic

Authored by tpopp on May 26 2023, 1:22 AM.

Details

Summary

The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change begins the migration of uses of the method to the
corresponding function call as has been decided as more consistent.

Note that there still exist classes that only define methods directly,
such as AffineExpr, and this does not include work currently to support
a functional cast/isa call.

This prefixes everything with llvm:: because some places require it, it would take more time to figure
out which subset of files don't need it, and they can be removed easily once the methods are removed.

Context:

Implementation:
This patch updates all remaining uses of the deprecated functionality in
mlir/. This was done with clang-tidy as described below and further
modifications to GPUBase.td and OpenMPOpsInterfaces.td.

Steps are described per line, as comments are removed by git:
0. Retrieve the change from the following to build clang-tidy with an

additional check:
main...tpopp:llvm-project:tidy-cast-check
  1. Build clang-tidy
  2. Run clang-tidy over your entire codebase while disabling all checks and enabling the one relevant one. Run on all header files also.
  3. Delete .inc files that were also modified, so the next build rebuilds them to a pure state.
ninja -C $BUILD_DIR clang-tidy

run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\
               -header-filter=mlir/ mlir/* -fix

rm -rf $BUILD_DIR/tools/mlir/**/*.inc

Diff Detail

Event Timeline

tpopp created this revision.May 26 2023, 1:22 AM
tpopp requested review of this revision.May 26 2023, 1:22 AM
tpopp edited the summary of this revision. (Show Details)May 26 2023, 1:24 AM
ftynse accepted this revision.May 26 2023, 1:28 AM
This revision is now accepted and ready to land.May 26 2023, 1:28 AM
This revision was landed with ongoing or failed builds.May 26 2023, 1:30 AM
This revision was automatically updated to reflect the committed changes.
mehdi_amini added inline comments.Jul 20 2023, 8:07 PM
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h
77

Why "dyn_cast_if_present"? These should all be non-null and dyn_cast should be enough?