This is an archive of the discontinued LLVM Phabricator instance.

[mlir] [transform] Fix for RAUW error in transform gpu dialect
ClosedPublic

Authored by guraypp on Nov 15 2022, 6:28 AM.

Details

Summary

The given test fails due to error below.

The following error is why the test is failing. One memref.store and two memref.load are consumers of the loop index for which I do RAUW. memref.store is first in the list. If I RAUW on this the loop of llvm::make early inc range(threadIdx.getUsers()) does not return two memref.load as users. They remain unchanged. I'm not really certain why.

This change applies RAUW after collecting the users. If a better solution exists, I would be happy to implement it.

mlir-opt: ...llvm-project/mlir/include/mlir/IR/UseDefLists.h:175: mlir::IRObjectWithUseList<mlir::OpOperand>::~IRObjectWithUseList() [OperandType = mlir::OpOperand]: Assertion `use_empty() && "Cannot destroy a value that still has uses!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

Diff Detail

Event Timeline

guraypp created this revision.Nov 15 2022, 6:28 AM
guraypp requested review of this revision.Nov 15 2022, 6:28 AM
guraypp updated this revision to Diff 475495.Nov 15 2022, 8:39 AM

Move invariant bvm.lookup(threadIdx) outside of the loop

guraypp updated this revision to Diff 475510.Nov 15 2022, 9:50 AM

Use vector constructor to build users.
Fix the same potential bug in map_foreach_to_blocks

mehdi_amini added inline comments.Nov 15 2022, 10:10 AM
mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
258

SetVector is heavy, do you need the ordering here?

Also are we sure that a set is better than accepting the eventual duplications?

I usually iterate over all uses (not users) with OpOperand::set, then there are no duplicates. (you still need the updaterootinplace on the owner and the set/vector)

mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
496

not needed anymore

springerm added inline comments.Nov 15 2022, 10:14 AM
mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
496

i meant the early_inc

guraypp updated this revision to Diff 475709.Nov 16 2022, 12:28 AM

Iterate over the uses instead of users
Use SmallVector instead of SetVector

springerm accepted this revision.Nov 16 2022, 12:31 AM
springerm added inline comments.
mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
254

nit: for (OpOperand *operand : uses) would be simpler

258

You can write operand->set(val)

500–504

same as above

mlir/test/Dialect/GPU/transform-gpu.mlir
197

nit: add new line

This revision is now accepted and ready to land.Nov 16 2022, 12:31 AM
guraypp updated this revision to Diff 475718.Nov 16 2022, 12:51 AM

address @springerm comments

This revision was landed with ongoing or failed builds.Nov 16 2022, 12:55 AM
This revision was automatically updated to reflect the committed changes.