-
Notifications
You must be signed in to change notification settings - Fork 186
[CIR] Fix handling of varargs and void-return builtins in intrinsic t… #2021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ype decoding Fix several issues in CIR intrinsic type construction for built-in functions such as printf (variadic) and void-return intrinsics. - Treat IITDescriptor::VarArg as a terminator marker rather than a type. It is now handled correctly in getIntrinsicType instead of decodeFixedType. - Added support for marking CIR function types as variadic. - Added proper handling of builtins returning void: CIRFuncType now omits an explicit void return type when appropriate. - Ensures correct CIR signatures for OpenCL and C built-ins that use ellipsis (printf) or return void (e.g. printf).
bcardosolopes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Also needs a testcase
|
Unfortunately I was not able to create a unit test that fails. I made a simple printf("...") test and it fails on the local repository of our project. Because we have a private version of print if. The CIR lowering looks like this: %6 = cir.llvm.intrinsic "private.printf" %5 : (!cir.ptr<!s8i>) -> !voidHowever using the original incubator repository the default built-in printf was used, so I did not hit the new code in this PR: %5 = cir.call @printf(%4) : (!cir.ptr<!s8i, addrspace(offload_constant)>) -> !s32i cc(spir_function) extra(#fn_attr)The change I made in this PR indeed fixes the private intrinsic case. |
Is this right? Is this what OG does? Looks like you need to fix more things in this PR so it can introduce a testcase? |
The issue is that getIntrinsicType in CIRGenBuiltin.cpp is only exercised for LLVM intrinsics, not normal builtins like printf. In our private repo, __private_printf is defined as a custom intrinsic, which triggers the bug. |
Gotcha, thanks for the explanation
Can't you synthetize that with a LLVM intrinsic that can be used within a kernel? (assuming one exists?) |
In this case printf is unique, I did not find other variadic built-in. I tried this but unfortunately didn't hit our flow: extern void __builtin_myvararg(void *format, ...);
__kernel void test() {
__builtin_myvararg(0);
} |
Fix several issues in CIR intrinsic type construction for built-in functions such as printf (variadic) and void-return intrinsics.