<span style="font-family: Tahoma, Geneva, sans-serif; font-size: 10pt">Hi Andrew,<div><br></div><div>this sounded a plausible explanation, because the X86 processor does not have an instruction to calculate the power function.</div><div><br></div><div>So I tried the llvm.sin.f32 intrinsic, as the X86 processor family does have an instruction for that, but I still get the same problem. While you may still be right, there is at least something else going on as well.<br><br><div></div>Thanks for your input, though.</div><div><br></div><div>Taco.<br><br><span style="font-family: tahoma,arial,sans-serif; font-size: 10pt;"><hr size="2" width="100%" align="center"><b>From</b>: "Andrew MacPherson" <andrew.macp@gmail.com><br><b>Sent</b>: Thursday, September 19, 2013 10:36 AM<br><b>To</b>: taco@heddesit.nl<br><b>Cc</b>: llvmdev@cs.uiuc.edu<br><b>Subject</b>: Re: [LLVMdev] JIT compiled intrinsics calls is call to null pointer</span><br><br><div dir="ltr"><div><div>Hi Taco,<br><br></div>We had a similar issue where a math intrinsic was being converted to a call to null and it turned out to be because the system didn't support the CPU instructions for the operation so the intrinsic used a call to the library function (pow in your case). However because we weren't expecting this math function to be looked up by MCJIT in our JITMemoryManager::getPointerToNamedFunction() we weren't making it available and it was returning null.<br>


<br></div>Not sure if this is relevant to your case but maybe it'll help point you in the right direction.<br><br>Cheers,<br>Andrew<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 18, 2013 at 8:32 AM, Taco H. in den Bosch <span dir="ltr"><<a href="mailto:taco@heddesit.nl" target="_blank">taco@heddesit.nl</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span style="font-family:Tahoma,Geneva,sans-serif;font-size:10pt"><br><font face="Arial, Verdana">Hi everyone,</font><div style="font-family:Arial,Verdana;font-size:10pt;font-style:normal;font-variant:normal;font-weight:normal;line-height:normal">

</div><div style="font-family:Arial,Verdana;font-size:10pt;font-style:normal;font-variant:normal;font-weight:normal;line-height:normal"><br></div><div style="font-family:Arial,Verdana;font-size:10pt;font-style:normal;font-variant:normal;font-weight:normal;line-height:normal">

I am trying to call an LLVM intrinsic (llvm.pow.f32), inserted with the following call:</div><div style="font-family:Arial,Verdana;font-size:10pt;font-style:normal;font-variant:normal;font-weight:normal;line-height:normal">

<br></div><div style="font-family:Arial,Verdana;font-size:10pt;font-style:normal;font-variant:normal;font-weight:normal;line-height:normal"><div>std::vector<llvm::Type *> arg_types;</div><div>arg_types.push_back(llvm::Type::getFloatTy(context));</div>

<div><span style="font-size:10pt">auto function=llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::pow, arg_types);</span></div></div><div><font face="Arial, Verdana">auto result=ir_builder->CreateCall(function, args);</font></div>

<div><font face="Arial, Verdana"><br></font></div><div><font face="Arial, Verdana">When I try to execute the code generated by the JIT compiler, I see that the intrinsic is not compiled into a math coprocessor instruction, but in a call to a null address:</font></div>

<div><font face="Arial, Verdana"><br></font></div><div><font face="Arial, Verdana">002300B8  sub         esp,8 </font></div><div><font face="Arial, Verdana"><div>002300BB  movss       xmm0,dword ptr ds:[2300B0h]  </div><div>

002300C3  movss       dword ptr [esp+4],xmm0  </div><div>002300C9  movss       xmm0,dword ptr ds:[2300B4h]  </div><div>002300D1  movss       dword ptr [esp],xmm0  </div><div>002300D6  <span style="background-color:rgb(255,255,0)">call        00000000</span>  </div>

<div>002300DB  add         esp,8  </div><div>002300DE  ret </div></font></div><div><font face="Arial, Verdana"><br></font></div><div><font face="Arial, Verdana">Is there anything special that I need to do in order to be able to call intrinsics, either in general or when JITting? I am either doing something wrong, or forgetting to do something, but I don't know what.</font></div>

<div><font face="Arial, Verdana"><br></font></div><div><font face="Arial, Verdana">I am working with a Visual Studio compiled version on Windows (x86).</font></div><div><font face="Arial, Verdana"><br></font></div><div><span style="font-family:Arial,Verdana;font-size:small">All hints will be appreciated, with kind regards,</span></div>

<div><span style="font-family:Arial,Verdana;font-size:small"><br></span></div><div><span style="font-family:Arial,Verdana;font-size:small">Taco H. in den Bosch.</span></div><div><span style="font-family:Arial,Verdana;font-size:small"><br>

</span></div><div style="font-family:Arial,Verdana;font-size:10pt;font-style:normal;font-variant:normal;font-weight:normal;line-height:normal"><br></div><div style="font-family:Arial,Verdana;font-size:10pt;font-style:normal;font-variant:normal;font-weight:normal;line-height:normal">

<br></div><div style="font-family:Arial,Verdana;font-size:10pt;font-style:normal;font-variant:normal;font-weight:normal;line-height:normal"><br></div></span>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div><br></div></span>