-
Notifications
You must be signed in to change notification settings - Fork 153
Implement translation of jmp msil instruction. #725
Conversation
jmp is implemented as a call marked with musttail followed by a ret. If the caller has a secret parameter we need to pass it to the jmp call because the signature and the calling convention of the caller and the musttail call must match. To accommodate that a parallel LLVM change modifies CLR_SecretParameter calling convention to make the secret parameter the first pointer-sized parameter (still passed in R10) rather than a parameter passed with a "CLR_SecretParameter" attribute. All indirect parameters are passed as they come to the caller, without copying them to the current frame. Indirect result parameter is typed as a managed pointer in a jmp call because we type indirect result parameter for the caller as a managed pointer. Closes dotnet#192.
@pgavlin PTAL |
@@ -312,7 +312,7 @@ CallSite ABICallSignature::emitUnmanagedCall(GenIR &Reader, Value *Target, | |||
|
|||
Value *ABICallSignature::emitCall(GenIR &Reader, Value *Target, bool MayThrow, | |||
ArrayRef<Value *> Args, | |||
Value *IndirectionCell, | |||
Value *IndirectionCell, bool IsJmp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that it looks like we'll need to do most (all?) of the transformations that are conditional on this parameter for tail calls as well, I wonder if it wouldn't be better to split this into bool IsTailCall, bool MustTailCall
(or bool IsTailCall, bool IsJmp
). Or maybe even something like:
enum CallKind
{
Normal = 0,
TailCall = 1,
MustTailCall =2
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jmp is different from tail.call. For example, tail.call doesn't have to have the same signature as the caller so we don't have to pass a secret parameter. I would rather keep this as IsJmp for now to make it clear that this code has only been implemented and tested for jmp. When we get to tail calls we will probably do something like what you suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that seems fine. You're right about the restrictions--I had misread the lang ref.
LGTM. |
llilc test failures are expected until corresponding llvm changes are in. |
Implement translation of jmp msil instruction.
jmp is implemented as a call marked with musttail followed by a ret.
If the caller has a secret parameter we need to pass it to the jmp call
because the signature and the calling convention of the caller and
the musttail call must match. To accommodate that a parallel
LLVM change modifies CLR_SecretParameter calling convention
to make the secret parameter the first pointer-sized parameter
(still passed in R10) rather than a parameter passed with a
"CLR_SecretParameter" attribute.
All indirect parameters are passed as they come to the caller, without
copying them to the current frame.
Indirect result parameter is typed as a managed pointer in a jmp call
because we type indirect result parameter for the caller as a
managed pointer.
Closes #192.