This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Move SCF utils implementations to SCF/Utils.
ClosedPublic

Authored by akuegel on Jan 26 2022, 4:29 AM.

Details

Summary

There are cases where other targets only use the utils, not the transforms.
So it makes sense to move them to their own target.

Diff Detail

Event Timeline

akuegel created this revision.Jan 26 2022, 4:29 AM
akuegel requested review of this revision.Jan 26 2022, 4:29 AM
herhut added a subscriber: herhut.Jan 26 2022, 4:39 AM
herhut added inline comments.
mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
51–52

Can one use the transforms without the utils? Otherwise maybe the former should depend on the latter.

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
2420

This is now outdated, as the files have moved.

akuegel added inline comments.Jan 26 2022, 4:49 AM
mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
51–52

Currently the transforms themselves use the Utils, which is why this dependency needs to be in this direction. Utils don't use Transforms though, which is why the split is even possible :)

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
2420

As far as I can tell, they are still in Dialect/SCF directory:

https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Dialect/SCF/Utils.h

We could move them also to a separate Utils subdirectory, then this exclude wouldn't be needed. But that would require also to changing several header includes. Might make sense to do in a followup patch?

akuegel added inline comments.Jan 26 2022, 7:29 AM
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
2420

Also, maybe I misunderstood the concern: the exclusion would not necessarily be needed because the headers are also part of the new target. But keeping them in this target has the opportunity to cause linker errors. Users of the headers might depend on the Dialect, but not on the Utils target with the implementation. This will work fine until a binary is built where the missing implementation dependency will be noticed.

rriddle added inline comments.Jan 26 2022, 10:20 PM
mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
13

Same here, can this be moved to SCF/Utils/AffineCanonicalizationUtils.h?

mlir/lib/Dialect/SCF/Utils/Utils.cpp
1

While you are here, can you fix this?

13

Can the header also be moved to SCF/Utils/Utils.h?

mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt
23

Why is transforms necessary now?

akuegel updated this revision to Diff 403527.Jan 27 2022, 12:25 AM

Address review comments.

akuegel marked 2 inline comments as done.Jan 27 2022, 12:27 AM
akuegel added inline comments.
mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt
23

It was already necessary before, mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp includes mlir/Dialect/SCF/Transforms.h
I noticed this missing dependency while comparing with the BUILD.bazel file.
If you prefer, I can land it in a separate change.

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
2420

River has also requested to move the headers, so I did that now as part of this patch. This makes it possible to remove the exclusion. I would still like to exclude Transforms.h, otherwise we have the same problem here that someone who uses SCFTransforms might forget to depend on that target. We already have a precedence for that case in the CMakeLists.txt file for SparseTensorTransforms which was missing this dependency (although this exclusion here won't fix cmake ;-) ).

rriddle accepted this revision.Jan 27 2022, 10:40 AM
rriddle added inline comments.
mlir/include/mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h
13–14

This will need a tweak.

mlir/include/mlir/Dialect/SCF/Utils/Utils.h
12–13

This will need a tweak.

This revision is now accepted and ready to land.Jan 27 2022, 10:40 AM
akuegel updated this revision to Diff 403901.Jan 27 2022, 11:24 PM

Adjust header guard.

akuegel marked 2 inline comments as done.Jan 27 2022, 11:26 PM
akuegel closed this revision.Jan 28 2022, 3:17 AM