Closed Kritoooo closed 2 weeks ago
Do we need to consider ABI problems here? @SchrodingerZhu pointed out that memref
type is not lowered to a pointer; instead it is a fat pointer that also captures various additional information such as the shape, see the comments for LLVMTypeConverter::getMemRefDescriptorFields
:
If ABI should be concerned we may revert this PR.
Do you mean that we should not simply convert cir.ptr to memref? If such a conversion has issues, you can revert this PR at any time.
However, I need to clarify that this PR only addresses the issue where cir.ptr or cir.vec (and similar types) cannot be correctly converted when used as function parameters. In the original lowering of FuncOp, due to the order of statements, the parameters carried by the entry block were converted multiple times (I am not exactly sure why; I pinpointed this statement using the debugger). Therefore, an error occurs in the final convertRegionTypes where the conversion cannot be completed. Regarding ABI, I'm not very familiar with it, so I can't provide useful assistance on that matter.
Do you mean that we should not simply convert cir.ptr to memref?
The semantics are equivalent, I'm just not sure if it's OK to break C/C++ ABI guarantees on the MLIR lowering path. If ABI is not the problem this lowering is good.
This PR is to fix the issue #658 . Now we can get the correct result using the following command.
result:
And the test/CIR/Lowering/ThroughMLIR/dot.cir now passes the test, so I have removed the XFAIL flag.