This is an archive of the discontinued LLVM Phabricator instance.

[mlir][LLVM] Add an attribute to control use of bare-pointer calling convention.
ClosedPublic

Authored by mravishankar on Apr 3 2023, 9:06 PM.

Details

Summary

Currently the use of bare pointer calling convention is controlled
globally through use of an option in the LLVMTypeConverter. To allow
more fine-grained control use an attribute on a function to drive the
calling convention to use.

Diff Detail

Event Timeline

mravishankar created this revision.Apr 3 2023, 9:06 PM

@ftynse I just tried something that allows more fine-grained control on the use of bare pointer calling convention (as we discussed a couple of weeks ago). This is by no means meant to be the end state, rather looking for suggestions on how to take this forward.

ftynse added inline comments.Apr 5 2023, 2:33 AM
mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
61

Nit: I'd rather prefix this with llvm, this isn't something func dialect needs to be aware of.

66

Nit: use the constant from above

283

Nit: TypeRange

ftynse added a comment.Apr 5 2023, 2:37 AM

This looks entirely reasonable to me as a start. The next step (potentially in a separate commit) could be to have the functionality that adds the attribute to all functions. With that in place, we can remove the current mechanism of forwarding the option in most places and just call that functionality before the main lowering happens.

mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
51

I think there are use cases for GPU funcs with bare pointers, so it's better for this to support the attribute as well.

mravishankar marked 2 inline comments as done.

Address comments and add tests. Make ready for review

mravishankar published this revision for review.Apr 5 2023, 11:47 PM
mravishankar added inline comments.
mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
66

Duh!!

mravishankar marked 2 inline comments as done.

Address missed comment.

@ftynse finished this patch up and is now ready for review.

ftynse accepted this revision.Apr 6 2023, 4:52 AM
ftynse added inline comments.
mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
279

Ultra-nit: s/base/bare.

This revision is now accepted and ready to land.Apr 6 2023, 4:52 AM