Skip to content

Conversation

@jakobbotsch
Copy link
Member

The pinvoke epilog is explicit on all our targets now, so it seems like this code should be unnecessary everywhere (and in any case, should not have been inside very general and very hot newRefPosition).

The pinvoke epilog is explicit on all our targets now, so it seems like
this code should be unnecessary everywhere (and in any case, should not
have been inside very general and very hot `newRefPosition`).
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 17, 2024
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jakobbotsch jakobbotsch marked this pull request as ready for review June 17, 2024 11:49
@jakobbotsch
Copy link
Member Author

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress, runtime-coreclr jitstressregs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jakobbotsch
Copy link
Member Author

jakobbotsch commented Jun 17, 2024

Failures are #103577, #103568, #103545, #102370, #102335, #102706

cc @dotnet/jit-contrib PTAL @kunalspathak

A few minor diffs, some good TP improvements.

@jakobbotsch jakobbotsch requested a review from kunalspathak June 17, 2024 17:25
@kunalspathak
Copy link
Contributor

The pinvoke epilog is explicit on all our targets now

Can you point to the relevant code? When I search for RBM_PINVOKE_TCB, other than lsrabuild.cpp, I just see it getting used for arm/x86.

@jakobbotsch
Copy link
Member Author

Can you point to the relevant code? When I search for RBM_PINVOKE_TCB, other than lsrabuild.cpp, I just see it getting used for arm/x86.

The pinvoke epilog is inserted as regular IR in lowering:

//------------------------------------------------------------------------
// InsertPInvokeMethodEpilog: Code that needs to be run when exiting any method
// that has PInvoke inlines. This needs to be inserted any place you can exit the
// function: returns, tailcalls and jmps.
//
// Arguments:
// returnBB - basic block from which a method can return
// lastExpr - GenTree of the last top level stmnt of returnBB (debug only arg)
//
// Return Value:
// Code tree to perform the action.
//
void Lowering::InsertPInvokeMethodEpilog(BasicBlock* returnBB DEBUGARG(GenTree* lastExpr))

I suspect the code I am removing here exists because at some point the pinvoke epilog was implicitly generated as part of epilog codegen (or perhaps GT_RETURN codegen). But since it is explicitly represented in IR today LSRA should already be handling the conflicts that may arise by normal means.

@kunalspathak
Copy link
Contributor

Does that mean we do not need RBM_PINVOKE_FRAME and need RBM_PINVOKE_TCB only for x86/arm?

@jakobbotsch
Copy link
Member Author

Does that mean we do not need RBM_PINVOKE_FRAME and need RBM_PINVOKE_TCB only for x86/arm?

REG_PINVOKE_FRAME is still used. It doesn't look like RBM_PINVOKE_FRAME has uses, but I guess it's nice to be consistent about making the mask versions available.

Both are only used in x86/arm32, so the definitions outside could be removed. Do you want me to do that as part of this PR?

@kunalspathak
Copy link
Contributor

REG_PINVOKE_FRAME is still used. It doesn't look like RBM_PINVOKE_FRAME has uses, but I guess it's nice to be consistent about making the mask versions available.

The only use I see for REG_PINVOKE_FRAME is this, which is for x86/arm, so we can just keep it for x86/arm and remove it from other targets.

#if defined(TARGET_X86) || defined(TARGET_ARM)
// The x86 and arm32 CORINFO_HELP_INIT_PINVOKE_FRAME helpers have a custom calling convention.
case WellKnownArg::PInvokeFrame:
return REG_PINVOKE_FRAME;

After this PR, there is no usage of RBM_PINVOKE_FRAME, so can get rid of that as well.

Both are only used in x86/arm32, so the definitions outside could be removed. Do you want me to do that as part of this PR?

Yes, that will be good.

@jakobbotsch
Copy link
Member Author

jakobbotsch commented Jun 18, 2024

After this PR, there is no usage of RBM_PINVOKE_FRAME, so can get rid of that as well.

There are plenty of other cases where we have REG_X and RBM_X where only one is used, but where both are defined. E.g. REG_EXCEPTION_OBJECT (unused) vs RBM_EXCEPTION_OBJECT (used), REG_R2R_INDIRECT_PARAM (used) vs RBM_R2R_INDIRECT_PARAM (unused), etc.

Like I mentioned above I think we should consistently define both versions, so I don't think we should remove the RBM version. But I can remove the definitions outside x86/arm32.

@kunalspathak
Copy link
Contributor

Like I mentioned above I think we should consistently define both versions, so I don't think we should remove the RBM version. But I can remove the definitions outside x86/arm32.

SGTM

Copy link
Contributor

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants