Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes for consecutive registers found with jitstressregs #84824

Merged
merged 12 commits into from
Apr 20, 2023

Conversation

kunalspathak
Copy link
Member

@kunalspathak kunalspathak commented Apr 14, 2023

  1. The register that was assigned previously to a copyReg scenario where not recorded as live at the location because of which we were reassigning it to a different variable, overwriting its value before consuming it for copy. This relates to my findings in [JitStress] VectorTableLookupExtension fails in jitstress1 #84696 (comment).
  2. When we generate code for upper vector restore, we were generating it at the use where FIELD_LIST is populated. But, between that and the intrinsic node, where it is consumed, there can be any number of nodes (like GT_CALL) where the restored upper half vectors can be again wiped off. Make sure to insert the restores just before the use of the FIELD_LIST node. This relates to my findings in [JitStress] VectorTableLookupExtension fails in jitstress1 #84696 (comment).
  3. There are numerous scenarios in which constraining the number of registers doesn't work with the consecutive registers because consecutive registers, itself constraints the registers that can be assigned. As such, I have added isLiveAtConsecutiveRegistersLoc and we will skip constraining the registers for such refpositions. However, to stress test the busy consecutive registers and free/busy code path, I have added a constraint on free registers that the algorithm sees under stress mode.

Fixes: #84747, #84696, #84746

@ghost ghost assigned kunalspathak Apr 14, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Apr 14, 2023
@ghost
Copy link

ghost commented Apr 14, 2023

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

Issue Details

null

Author: kunalspathak
Assignees: kunalspathak
Labels:

area-CodeGen-coreclr

Milestone: -

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstress

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstressregs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstress2-jitstressregs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

This method will track if the defs/uses are live at the same location as
where the consecutive registers were allocated. If yes, it will skip the
constraint imposition on it during JitStressRegs
When we have copyReg that was just restored or previously assigned
to a different register, also track it as live at the location so
it doesn't get allocated again for different refposition at the same
location.
@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstress

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstress2-jitstressregs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstressregs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

…isters

Under JitStressRegs, there are multiple ways in which consecutive registers demand
cannot be met. So skip restricting the registers for `registerAssignment` of a refPosition
(which are allowable candidates that can be assigned to the given refposition). Instead
limit the free registers to alternate under stress mode, so we can verify the code if it
can handle situation where it needs to pick from a mix of free/busy registers.
@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstress
/azp run runtime-coreclr jitstress2-jitstressregs
/azp run runtime-coreclr jitstress2-jitstressregs

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstress

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstress2-jitstressregs

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr jitstressregs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

2 similar comments
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kunalspathak
Copy link
Member Author

All the CI legs are passing. There is failures on x64 for which I have opened #84961. There are failures in JIT/IL_Conformance/Old/Conformance_Base/ for arm64 which are unlikely to be affected by this change. I have started a run for jitstress on main just to confirm it is not related.

@kunalspathak
Copy link
Member Author

I have started a run for jitstress on main just to confirm it is not related.

They are on main as well. Opened #84966.

@kunalspathak kunalspathak marked this pull request as ready for review April 18, 2023 05:29
@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib @BruceForstall

@kunalspathak kunalspathak changed the title restore the upper vector at the use of GT_FIELD_LIST Various fixes for consecutive registers found with jitstressregs Apr 18, 2023
src/coreclr/jit/lsra.h Outdated Show resolved Hide resolved
@kunalspathak
Copy link
Member Author

ping @BruceForstall

@kunalspathak
Copy link
Member Author

Adding the links for green runs :
jitstress2-jitstressregs , jitstressregs and jitstress

@@ -1784,6 +1784,12 @@ class LinearScan : public LinearScanInterface
void clearSpillCost(regNumber reg, var_types regType);
void updateSpillCost(regNumber reg, Interval* interval);

FORCEINLINE void updateRegsFreeBusyState(RefPosition& refPosition,
Copy link
Member

Choose a reason for hiding this comment

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

Is it really necessary to use FORCEINLINE?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is hot functionality used whenever we assign copyRegs with or without consecutive registers. I didn't want to impact the TP for just extracting out this functionality in a method.

src/coreclr/jit/lsraarm64.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/lsraarm64.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/lsrabuild.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/lsra.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/lsra.cpp Outdated Show resolved Hide resolved
@kunalspathak kunalspathak merged commit 42acf9e into dotnet:main Apr 20, 2023
@kunalspathak kunalspathak deleted the consecutive-jitstress branch April 20, 2023 00:06
@ghost ghost locked as resolved and limited conversation to collaborators May 20, 2023
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.

Assertion failed 'refPosition->RegOptional()'
2 participants