Normalizing memrefs failed when a caller of symbolic use in a function
can not be casted to CallOp. This patch avoids the failure by checking
the result of the casting. If the caller can not be casted to CallOp,
it is skipped.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This bug was discussed here https://llvm.discourse.group/t/memrefs-and-maps-for-tiling/1279/21
Following example failed because spv.EntryPoint "GLCompute" @empty can't be casted to CallOp. I created the example to reproduce errors happened in my code which uses EntryPoint op of my own dialect. This example may not be practical, but this reproduced the same error with my code.
#map0 = affine_map<(d0, d1) -> (d0 floordiv 32, d1 floordiv 64, d0 mod 32, d1 mod 64)> module { func @empty() { %0 = alloc() : memref<10x10xf32, #map0> return } spv.EntryPoint "GLCompute" @empty }
@bondhugula @avarmapml Could you review this patch?
Thanks for raising this. Please add a test case. It's not fully clear one could just ignore all uses that aren't CallOps. Please also add a comment.
mlir/lib/Transforms/NormalizeMemRefs.cpp | ||
---|---|---|
266–276 | Please rename variables for better readability. callOp -> userOp Also, please invert the logic for clarity. auto callOp = dyn_cast<CallOp>(userOp); if (!callOp) continue; StringRef callee = castCallOp.getCallee(); |
Thank you for raising this.
Solution looks good to me. Please add the test case though.
@bondhugula @avarmapml Thanks for your comments! I added test and comments, and renamed the variables to reflect @bondhugula 's comments.
mlir/lib/Transforms/NormalizeMemRefs.cpp | ||
---|---|---|
271–272 | You can rephrase this line as :- |
mlir/test/Transforms/normalize-memrefs-ops.mlir | ||
---|---|---|
59 | -> Test with an arbitrary op that references the symbol Nit: Terminate all comments with period. | |
mlir/test/lib/Dialect/Test/TestOps.td | ||
632 | Nit: terminate comment with a period. | |
632 | including entrypoint -> including a reference to a function symbol. | |
643 | Nit: Drop extra blank line. |
mlir/test/lib/Dialect/Test/TestOps.td | ||
---|---|---|
636 | It's still not clear what this means. Did you mean to say it's an arbitrary op with a reference to a function symbol? Why is even an entry point in the context here? |
mlir/test/lib/Dialect/Test/TestOps.td | ||
---|---|---|
636 | A op for entry point issued the error in my actual use case. So, I created the test op for entry point, but as you said, we should make it more general. OPEntryPoint -> OPFuncRef |
mlir/test/lib/Dialect/Test/TestOps.td | ||
---|---|---|
632 | @AlexEichenberger This is a two line-comment. Is it ok as it is? // Test for memrefs normalization of an op with a reference to a function // symbol. Thanks! |
@bondhugula @AlexEichenberger @avarmapml Do you have any other comments?
I think I don't have right to commit. So, could you commit this patch if this is ready?
@bondhugula It seems there is no additional comments. Could you commit also this patch?
You can rephrase this line as :-
TODO: Handle cases where a non-CallOp symbol use of a function deals with memrefs.