marwayusuf@feng.bu.edu.eg
2015-May-30 13:24 UTC
[LLVMdev] How patchpoint intrinsic actually patches?
Dear All I have some questions about how to use patchpoint intrinsic: 1- The function that is provided as argument to the intrinsic call, where does it belong? I'm making a pass to change a given IR file and add call to patchpoint. Where should I put this function? In the pass or in the same IR file or in another IR and include it or what? 2- When actually this code is patched into the original code and executed? Upon some condition or signal or it's patched by default whenever it's met in code? If it's patched automatically, what is its advantage then? Thanks in advance. Regards, Marwa Yusuf Teaching Assistant - Computer Engineering Department Faculty of Engineering - Benha University E-JUST MSc Student Computer Science & Engineering Dept. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150530/0e0a1ba9/attachment.html>
Marius Wachtler
2015-May-30 14:09 UTC
[LLVMdev] How patchpoint intrinsic actually patches?
Hi, The patchpoint intrinsic just takes a pointer to the function it should call. It doesn't care where the address points to e.g. could by a function in the same module or the address of some functions inside the application. When the machine code gets emitted the patchpoint will get replaced with a call instruction to the address specified inside the intrinsic before + additional nop instructions depending on the numBytes param of the patchpoint. So you don't actually have to patch the patchpoint if calling the supplied address is fine. Pyston uses the patchpoint intrinsic to emit a call to the slowpath function (e.g. a function which can handle all object types). This function when called will determine from where it got called to retrieve the corresponding stackmap entry and determine the actual types of the args it got called. It will then replace the call+nop from the patchpoint with a type check and a call to the faster type dependent function and a call to the slowpath function in case the types change. You will have to do the patching on you own. Hope this helps. On Sat, May 30, 2015 at 3:24 PM, marwayusuf at feng.bu.edu.eg < marwayusuf at feng.bu.edu.eg> wrote:> Dear All > > I have some questions about how to use patchpoint intrinsic: > > 1- The function that is provided as argument to the intrinsic call, where > does it belong? I'm making a pass to change a given IR file and add call > to patchpoint. Where should I put this function? In the pass or in the same > IR file or in another IR and include it or what? > > 2- When actually this code is patched into the original code and executed? > Upon some condition or signal or it's patched by default whenever it's met > in code? If it's patched automatically, what is its advantage then? > > Thanks in advance. > > > Regards, > Marwa Yusuf > Teaching Assistant - Computer Engineering Department > Faculty of Engineering - Benha University > E-JUST MSc Student > Computer Science & Engineering Dept. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150530/7773154f/attachment.html>