[llvm-dev] Question about using IRBuilder::CreateIntrinsic for a variadic intrinsic
Nicolai Hähnle via llvm-dev
llvm-dev at lists.llvm.org
Wed Oct 7 12:07:48 PDT 2020
On Mon, Oct 5, 2020 at 10:28 PM Riyaz Puthiyapurayil via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Should I omit the actual argument types corresponding to the variadic arguments? Is that how CreateIntrinsic should be called?
CreateIntrinsic expects you to pass _only_ the types corresponding to
llvm_any*_ty types.
Cheers,
Nicolai
>
>
>
> 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
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--
Lerne, wie die Welt wirklich ist,
aber vergiss niemals, wie sie sein sollte.
More information about the llvm-dev
mailing list