[llvm-dev] Question about using IRBuilder::CreateIntrinsic for a variadic intrinsic

Riyaz Puthiyapurayil via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 5 13:28:31 PDT 2020


Should I omit the actual argument types corresponding to the variadic arguments? Is that how CreateIntrinsic should be called?

From: Riyaz Puthiyapurayil
Sent: Monday, October 5, 2020 12:30 PM
To: llvm-dev at lists.llvm.org
Subject: Question about using IRBuilder::CreateIntrinsic for a variadic intrinsic


I have a variadic intrinsic that is defined as something like this:



def int_foobar : Intrinsic<[llvm_anyint_ty],

                            [llvm_vararg_ty],

                            [IntrNoMem, IntrSpeculatable]>;





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?



/Riyaz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201005/bb73cc4d/attachment.html>


More information about the llvm-dev mailing list