<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Lang,</div><div class=""><br class=""></div><div class="">you know that I like this feature, so you won’t hear any objections from me - especially for the experimental version of patchpoint.</div><div class="">We will have to revisit this when we do the “non-experimental” version of the intrinsic (e.g get rid of the bitcast), but that is for another time.</div><div class=""><br class=""></div><div class="">I am only wondering about the materialization part. Should we call the symbol directly and use a trampoline when it is out of range? I thought you already implemented that in RuntimeDyld. That way we could use the same code sequence for all code models.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Juergen</div><div class=""><br class=""></div><div class="">PS: Please also update the patchpoint documentation.</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 31, 2015, at 5:25 PM, Lang Hames <<a href="mailto:lhames@gmail.com" class="">lhames@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi All,<div class=""><br class=""></div><div class="">At the moment llvm.patchpoint call targets must be integer constants (e.g. 0xDEADBEEF). This patch adds support for symbolic targets like @foo, which addresses a couple of FIXMEs.</div><div class=""><br class=""></div><div class="">Making this work just involved teaching FastISel and SelectionDAG to construct the appropriate MI/SDNodes, and teaching the Targets how to lower these to MCInsts. Target support for x86 is included in this patch. Support for other targets should be easy to derive from that.</div><div class=""><br class=""></div><div class="">With this patch applied, you can write patchpoints of the following form:</div><div class=""><br class=""></div><font face="monospace, monospace" class="">tail call i64 (i64, i32, i8*, i32, ...)*</font><div class=""><span style="font-family:monospace,monospace" class="">  @llvm.experimental.patchpoint.void(i64 9, i32 15,</span></div><div class=""><span style="font-family:monospace,monospace" class="">    i8* bitcast (i64 (i64, i64)* @foo to i8*),      ; <- Call target</span></div><div class=""><span style="font-family:monospace,monospace" class="">    i32 2, i64 %p1, i64 %p2)</span><div class=""><br class=""></div><div class="">and this will generate:</div><div class=""><br class=""></div><font face="monospace, monospace" class="">movabsq $_foo, %r11<br class="">callq   *%r11<br class="">// <nop-padding></font><div class=""><br class=""></div><div class="">For integer targets this would have been something like:</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">movabsq $0xDEADBEEF, %r11<br class="">callq   *%r11<br class="">// <nop-padding></font><br class=""></div><div class=""><br class=""></div><div class="">The advantage of symbolic targets, beyond improved readability, is that you can cache the IR or compiled objects and re-use them in contexts where the target address may have changed. For example, objects that use symbolic patchpoints can be cached in Orc/MCJIT object-caches and re-used across JIT invocations.</div><div class=""><br class=""></div><div class="">Immediate-address targets are still fully supported.</div><div class=""><br class=""></div><div class="">I don't really see any downside to this patch, but I thought I'd throw it out for general discussion before I go and widen what patchpoint is supposed to support.</div><div class=""><br class=""></div><div class="">Does anyone see any problem with this idea?</div><div class=""><br class=""></div><div class="">For the curious, my motivation is that I'd like (eventually) to support patchpoints for JIT re-entry in Orc as an alternative to indirect calls, and I want that transformation to be straightforward. E.g.</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">call @not_yet_compiled, ...</font></div><div class="">to</div><div class=""><font face="monospace, monospace" class="">call llvm.patchpoint ..., @not_yet_compiled, ...</font></div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Lang.</div></div></div>
<span id="cid:EF7CEA24-1227-4D77-BA52-32BC58B6E0E1@apple.com"><symbolic_patchpoints.patch></span></div></blockquote></div><br class=""></body></html>