Skip to content

Conversation

@jakobbotsch
Copy link
Member

During prolog generation we sometimes generate code to call the profiler enter callback. This may trash the "initReg" that we expect to keep zeroed during the prolog. The logic to check if the initReg was being trashed was wrong in a couple of cases:

  • Most backends did not take into account that the logic also trashes the registers used for arguments to the enter callback
  • SysV x64 thought that the enter callback trashed the parameter registers, but it does not

This generally did not cause issues because genFnPrologCalleeRegArgs is unnecessarily conservative around whether or not it trashes initReg, and it comes after the profiler callback in the prolog. However, with the rewrite of the homing function that is not going to be the case anymore.

Fixes an issue I noticed by inspection over in #100572

During prolog generation we sometimes generate code to call the profiler
enter callback. This may trash the "initReg" that we expect to keep
zeroed during the prolog. The logic to check if the initReg was being
trashed was wrong in a couple of cases:
- Most backends did not take into account that the logic also trashes
  the registers used for arguments to the enter callback
- SysV x64 thought that the enter callback trashed the parameter
  registers, but it does not

This generally did not cause issues because `genFnPrologCalleeRegArgs`
is unnecessarily conservative around whether or not it trashes
`initReg`, and it comes after the profiler callback in the prolog.
However, with the rewrite of the homing function that is not going to be
the case anymore.
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Apr 4, 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
Copy link
Member Author

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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@jakobbotsch jakobbotsch marked this pull request as ready for review April 4, 2024 19:14
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @BruceForstall

@BruceForstall
Copy link
Contributor

No diffs -- so no test coverage?

@jakobbotsch
Copy link
Member Author

No diffs -- so no test coverage?

We have test coverage in stress due to STRESS_PROFILER_CALLBACKS. I hit the problem over in #100572. There it wasn't a problem in the baseline because genFnPrologCalleeRegArgs mistakenly was marking the initReg as clobbered (even though it didn't actually end up using it for anything).

@jakobbotsch jakobbotsch merged commit 96d5a66 into dotnet:main Apr 4, 2024
@jakobbotsch jakobbotsch deleted the profiler-trashed branch April 4, 2024 19:33
matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
During prolog generation we sometimes generate code to call the profiler
enter callback. This may trash the "initReg" that we expect to keep
zeroed during the prolog. The logic to check if the initReg was being
trashed was wrong in a couple of cases:
- Most backends did not take into account that the logic also trashes
  the registers used for arguments to the enter callback
- SysV x64 thought that the enter callback trashed the parameter
  registers, but it does not

This generally did not cause issues because `genFnPrologCalleeRegArgs`
is unnecessarily conservative around whether or not it trashes
`initReg`, and it comes after the profiler callback in the prolog.
However, with the rewrite of the homing function that is not going to be
the case anymore.
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2024
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