I have a variadic intrinsic that is defined as something like this:
def int_foobar : Intrinsic<[llvm_anyint_ty],
When I construct a call to the above intrinsic with IRBuilder::CreateIntrinsic, it mangles the intrinsic name with the return type (i64) and the actual argument types i32.i32. The mangled name then becomes @llvm.foobar.i64.i32.i32
However this causes the Verifier to fail with:
Intrinsic name not mangled correctly for type arguments! Should be: llvm.foobar.i64
It seems to me the problem occurs when the return type is overloaded. If I change the return type for the intrinsic in Intrinsics.td from llvm_anyint_ty to a specific type, say llvm_i64_ty, then it works without any issues.
Is this a limitation or a bug in the verifier or builder? Should I explicitly create a declaration for the intrinsic for each return type, before calling IRBuilder::CreateIntrinsic? I haven’t checked it if it would work in my code (but writing it like that in assembly and making the calls seems to work). More specifically the following works (declaring before or after the call seems to work in assembly):
%a = call i64 (…) @llvm.foobar.i64(i32 %b, i32 %xc)
declare i64 @llvm.foobar.i64(…)
Any comments? How is the call to such an intrinsic supposed to be constructed with IRBuilder?