From 4a544a79bd735967f1d33fe675ae4566dbd17813 Mon Sep 17 00:00:00 2001
From: Duncan Sands
This intrinsic makes it possible to excise one parameter, marked with +
These intrinsics make it possible to excise one parameter, marked with the nest attribute, from a function. The result is a callable function pointer lacking the nest parameter - the caller does not need to @@ -7702,7 +7703,8 @@ LLVM.
%tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86 %tramp1 = getelementptr [10 x i8]* %tramp, i32 0, i32 0 - %p = call i8* @llvm.init.trampoline(i8* %tramp1, i8* bitcast (i32 (i8*, i32, i32)* @f to i8*), i8* %nval) + call i8* @llvm.init.trampoline(i8* %tramp1, i8* bitcast (i32 (i8*, i32, i32)* @f to i8*), i8* %nval) + %p = call i8* @llvm.adjust.trampoline(i8* %tramp1) %fp = bitcast i8* %p to i32 (i32, i32)*@@ -7720,12 +7722,12 @@ LLVM.
- declare i8* @llvm.init.trampoline(i8* <tramp>, i8* <func>, i8* <nval>) + declare void @llvm.init.trampoline(i8* <tramp>, i8* <func>, i8* <nval>)
This fills the memory pointed to by tramp with code and returns a - function pointer suitable for executing it.
+This fills the memory pointed to by tramp with executable code, + turning it into a trampoline.
The llvm.init.trampoline intrinsic takes three arguments, all @@ -7739,17 +7741,50 @@ LLVM.
The block of memory pointed to by tramp is filled with target - dependent code, turning it into a function. A pointer to this function is - returned, but needs to be bitcast to an appropriate - function pointer type before being called. The new function's signature - is the same as that of func with any arguments marked with - the nest attribute removed. At most one such nest argument - is allowed, and it must be of pointer type. Calling the new function is - equivalent to calling func with the same argument list, but - with nval used for the missing nest argument. If, after - calling llvm.init.trampoline, the memory pointed to - by tramp is modified, then the effect of any later call to the - returned function pointer is undefined.
+ dependent code, turning it into a function. Then tramp needs to be + passed to llvm.adjust.trampoline to get a pointer + which can be bitcast (to a new function) and + called. The new function's signature is the same as that of + func with any arguments marked with the nest attribute + removed. At most one such nest argument is allowed, and it must be of + pointer type. Calling the new function is equivalent to calling func + with the same argument list, but with nval used for the missing + nest argument. If, after calling llvm.init.trampoline, the + memory pointed to by tramp is modified, then the effect of any later call + to the returned function pointer is undefined. ++ declare i8* @llvm.adjust.trampoline(i8* <tramp>) ++ +
This performs any required machine-specific adjustment to the address of a + trampoline (passed as tramp).
+ +tramp must point to a block of memory which already has trampoline code + filled in by a previous call to llvm.init.trampoline + .
+ +On some architectures the address of the code to be executed needs to be + different to the address where the trampoline is actually stored. This + intrinsic returns the executable address corresponding to tramp + after performing the required machine specific adjustments. + The pointer returned can then be bitcast and + executed. +