<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 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’ve been working on the MCJIT interface today.  There are a lot of ugly things there as a result of sharing a base class with the old JIT engine.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">With regard to the getPointerToX functions, I was thing about adding new methods getXAddress that return uint64_t values and calling the old ones deprecated. 
 I’m not sure that helps with the C API, but I thought I’d mention it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Is there any reason not to have this function return a uint64_t?  Even the void pointer would need to be cast to something else to be useful.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">BTW, the current implementation of MCJIT::runFunction() will definitely not work if the target is remote.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-Andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> llvm-commits-bounces@cs.uiuc.edu [mailto:llvm-commits-bounces@cs.uiuc.edu]
<b>On Behalf Of </b>Jim Grosbach<br>
<b>Sent:</b> Thursday, September 19, 2013 2:27 PM<br>
<b>To:</b> Filip Pizlo<br>
<b>Cc:</b> llvm-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [llvm] r191030 - llvm-c: Add LLVMGetPointerToFunction<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Sep 19, 2013, at 2:04 PM, Filip Pizlo <<a href="mailto:fpizlo@apple.com">fpizlo@apple.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Sep 19, 2013, at 1:49 PM, Jim Grosbach <<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><br>
On Sep 19, 2013, at 1:46 PM, Filip Pizlo <<a href="mailto:fpizlo@apple.com">fpizlo@apple.com</a>> wrote:<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">How is that different from LLVMGetPointerToGlobal()?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">It’s not. That’s broken, too.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">And I agree that this should work.  It's great that the JIT could be used for remote execution, but some clients will never use the JIT in that fashion.  They will just
 want a void*.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Then they will use a memory manager that can make additional guarantees such as the opaque uint64_t value is actual just a bitcasted local pointer which can be safely cast
 back to void* or whatever. That’s a client-process usage, however, and not a guarantee of the JIT API.<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Are you saying that if a LLVM C API client doesn't install a custom memory manager, then the MCJIT is semantically permitted to JIT the code into a remote process?<o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">No, I’m saying the API has to be semantically rich enough to be agnostic about remote vs. local. That’s a function of the memory manager interface. The default memory manager does indeed to local currently. I have mixed feelings about making
 that an explicit guarantee.<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">Currently the C API has no facility for asking for code to be JITed into something remote, and it seems like it would be a bug if the JIT did this without the client asking for it.  It makes far more sense to me that the C API continues
 to have a hard constraint that JITing is local, and that the end result is a function that lives in your address space.<o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">I strongly disagree. The C API is about exposing functionality, not imposing additional constraints.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-Jim<o:p></o:p></p>
</div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><br>
<br>
<o:p></o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">On Sep 19, 2013, at 1:36 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Hrm. That's a good point and one I hadn't thought about... what's the<br>
best way forward here? There's definitely a useful need in getting a<br>
void * to a function out of the JIT from the C level.<br>
<br>
-eric<br>
<br>
On Thu, Sep 19, 2013 at 1:30 PM, Jim Grosbach <<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>> wrote:<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">This isn’t going to work when the execution target isn’t local. The pointer to the function is in the executing process address space and this returns a pointer in the compiler’s
 address space.<br>
<br>
That’s a fundamental problem with the old JIT, and is semi-baked into the ExecutionEngine API, unfortunately, and cleaning that up is going to be painful. We shouldn’t, however, make the problem worse.<br>
<br>
-Jim<br>
<br>
On Sep 19, 2013, at 12:55 PM, Anders Waldenborg <<a href="mailto:anders@0x63.nu">anders@0x63.nu</a>> wrote:<br>
<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Author: andersg<br>
Date: Thu Sep 19 14:55:06 2013<br>
New Revision: 191030<br>
<br>
URL:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=191030&view=rev">http://llvm.org/viewvc/llvm-project?rev=191030&view=rev</a><br>
Log:<br>
llvm-c: Add LLVMGetPointerToFunction<br>
<br>
Differential Revision:<span class="apple-converted-space"> </span><a href="http://llvm-reviews.chandlerc.com/D1715">http://llvm-reviews.chandlerc.com/D1715</a><br>
<br>
<br>
Modified:<br>
  llvm/trunk/include/llvm-c/ExecutionEngine.h<br>
  llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp<br>
<br>
Modified: llvm/trunk/include/llvm-c/ExecutionEngine.h<br>
URL:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/ExecutionEngine.h?rev=191030&r1=191029&r2=191030&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/ExecutionEngine.h?rev=191030&r1=191029&r2=191030&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm-c/ExecutionEngine.h (original)<br>
+++ llvm/trunk/include/llvm-c/ExecutionEngine.h Thu Sep 19 14:55:06 2013<br>
@@ -141,6 +141,8 @@ LLVMGenericValueRef LLVMRunFunction(LLVM<br>
                                   unsigned NumArgs,<br>
                                   LLVMGenericValueRef *Args);<br>
<br>
+void *LLVMGetPointerToFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);<br>
+<br>
void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);<br>
<br>
void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M);<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp<br>
URL:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp?rev=191030&r1=191029&r2=191030&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp?rev=191030&r1=191029&r2=191030&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Thu Sep 19 14:55:06 2013<br>
@@ -276,6 +276,10 @@ LLVMGenericValueRef LLVMRunFunction(LLVM<br>
 return wrap(Result);<br>
}<br>
<br>
+void *LLVMGetPointerToFunction(LLVMExecutionEngineRef EE, LLVMValueRef F) {<br>
+  return unwrap(EE)->getPointerToFunction(unwrap<Function>(F));<br>
+}<br>
+<br>
void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F) {<br>
 unwrap(EE)->freeMachineCodeForFunction(unwrap<Function>(F));<br>
}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>