<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoPlainText">I have a variadic intrinsic that is defined as something like this:<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><b><span style="font-family:Consolas">def int_foobar : Intrinsic<[llvm_anyint_ty],<o:p></o:p></span></b></p>
<p class="MsoPlainText"><b><span style="font-family:Consolas"> [llvm_vararg_ty],<o:p></o:p></span></b></p>
<p class="MsoPlainText"><b><span style="font-family:Consolas"> [IntrNoMem, IntrSpeculatable]>;<o:p></o:p></span></b></p>
<p class="MsoPlainText"><b><o:p> </o:p></b></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">When I construct a call to the above intrinsic with <span style="font-family:Consolas">
IRBuilder::CreateIntrinsic</span>, it mangles the intrinsic name with the return type (<span style="font-family:Consolas">i64</span>) and the actual argument types
<span style="font-family:Consolas">i32.i32</span>. The mangled name then becomes
<b><span style="font-family:Consolas">@llvm.foobar.i64.i32.i32</span></b> <o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">However this causes the Verifier to fail with:<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><b><span style="font-family:Consolas">Intrinsic name not mangled correctly for type arguments! Should be: llvm.foobar.i64<o:p></o:p></span></b></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">It seems to me the problem occurs when the return type is overloaded. If I change the return type for the intrinsic in
<span style="font-family:Consolas">Intrinsics.td</span> from <span style="font-family:Consolas">
llvm_anyint_ty</span> to a specific type, say <span style="font-family:Consolas">
llvm_i64_ty</span>, then it works without any issues.<o:p></o:p></p>
<p class="MsoPlainText"><b><o:p> </o:p></b></p>
<p class="MsoPlainText">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
<span style="font-family:Consolas">IRBuilder::CreateIntrinsic</span>? 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):<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><b><span style="font-family:Consolas"> %a = call i64 (…) @llvm.foobar.i64(i32 %b, i32 %xc)<o:p></o:p></span></b></p>
<p class="MsoPlainText"><b><span style="font-family:Consolas">:<o:p></o:p></span></b></p>
<p class="MsoPlainText"><b><span style="font-family:Consolas">:<o:p></o:p></span></b></p>
<p class="MsoPlainText"><b><span style="font-family:Consolas">declare i64 @llvm.foobar.i64(…)<o:p></o:p></span></b></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Any comments? How is the call to such an intrinsic supposed to be constructed with
<span style="font-family:Consolas">IRBuilder</span>?<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">/Riyaz<o:p></o:p></p>
</div>
</body>
</html>