Displaying 1 result from an estimated 1 matches for "new_arg1".
Did you mean:
new_argv
[LLVMdev] PSA: Perfectly forwarding thunks can now be expressed in LLVM IR with musttail and varargs
2014 Sep 02
2
[LLVMdev] PSA: Perfectly forwarding thunks can now be expressed in LLVM IR with musttail and varargs
I needed this functionality to solve http://llvm.org/PR20653, but it
obviously has far more general applications.
You can do it like this:
define i32 @my_forwarding_thunk(i32 %arg1, i8* %arg2, ...) {
... ; define new_arg1 and new_arg2
%r = musttail call i32 (i32, i8*, ...)* @the_true_target(i32 %new_arg1,
i8* %new_arg2, ...)
ret i32 %r
}
declare i32 @the_true_target(i32, i8*, ...)
The varargs convention (usually) matches the standard function call
convention, and everything will line up if you do an indirect ca...