<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
The two options listed so far (inline asm and patchable code via
patchpoints/statepoints) are definitely your best options if the
call via memory is a functional requirement.<br>
<br>
If you're willing to live with some chance LLVM emits different
code, you could try representing the function pointer as an external
global variable in the Module with the call and then linking it with
a Module which contains the constant value of the global. My guess
- haven't checked - is that this would generally result in the code
generation you want. This would mostly be useful for an experiment
or an optimization, not for fulfilling a functional or ABI
requirement.<br>
<br>
Philip<br>
<br>
<br>
<div class="moz-cite-prefix">On 08/21/2015 09:28 AM, John Criswell
via llvm-dev wrote:<br>
</div>
<blockquote cite="mid:55D751A7.10906@gmail.com" type="cite">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<div class="moz-cite-prefix">Dear Eugene,<br>
<br>
I think the best way to do this is to generate inline assembly
code at the LLVM IR level that uses the memory-based addressing
mode that you want. Any other approach could break with
changes/enhancements to the LLVM code generator.<br>
<br>
The only other way to do this is to write an LLVM
MachineFunctionPass, but that is probably overkill for what
you're trying to do.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
<br>
On 8/17/15 6:41 PM, Eugene Rozenfeld via llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:BLUPR03MB18140F0EF1E8165741B331591790@BLUPR03MB181.namprd03.prod.outlook.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<div class="WordSection1">
<p class="MsoNormal">I’d like to generate an indirect call
instruction that will end up as a call via memory and not
register.</p>
<p class="MsoNormal">The address of the target is a constant.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">For example, something like</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">%25 = load i64, i64* @get_Now</p>
<p class="MsoNormal">%26 = inttoptr i64 %25 to i64 ()*</p>
<p class="MsoNormal">%27 = call i64 %26()</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">may end up as</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">mov rsi,qword ptr [00007FF658381070]</p>
<p class="MsoNormal">call rsi</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">or as</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">call qword ptr [00007FF658381070]</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">If I want to guarantee that the second
form is always used, how would I go about that?</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">One possibility is to use patchpoints (<a
moz-do-not-send="true"
href="http://llvm.org/docs/StackMaps.html#id9">http://llvm.org/docs/StackMaps.html#id9</a>).
Are there any other alternatives?</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Eugene</p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a> <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell">http://www.cs.rochester.edu/u/criswell</a></pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>