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

JIT: Split out call importation into new importercalls.cpp #76792

Merged
merged 10 commits into from
Oct 10, 2022

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Oct 9, 2022

No code changes yet, purely moving the code.

@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 Oct 9, 2022
@ghost ghost assigned jakobbotsch Oct 9, 2022
@ghost
Copy link

ghost commented Oct 9, 2022

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

Issue Details

No code changes yes, purely moving code.

Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

@EgorBo
Copy link
Member

EgorBo commented Oct 9, 2022

we already have importer_vectorization.cpp should we have importer_call.cpp ?

@jakobbotsch
Copy link
Member Author

we already have importer_vectorization.cpp should we have importer_call.cpp ?

Most of the JIT files do not use underscores as separators so I'm not really sure. Seems like importer_vectorization is the odd one out.

@jakobbotsch
Copy link
Member Author

Maybe we should rename importer_vectorization.cpp -> stringintrinsics.cpp to make it consistent with hwintrinsics.cpp?

@EgorBo
Copy link
Member

EgorBo commented Oct 9, 2022

we already have importer_vectorization.cpp should we have importer_call.cpp ?

Most of the JIT files do not use underscores as separators so I'm not really sure. Seems like importer_vectorization is the odd one out.

Feel free to fix that but currently it looks inconsistent. I'd prefer %phase name%%what it does% -- similar to LLVM: https://github.com/llvm/llvm-project/tree/main/llvm/lib/Transforms/InstCombine InstCombine phase splitted to InstCombineCalls, InstCombineCasts, etc

@EgorBo
Copy link
Member

EgorBo commented Oct 9, 2022

Maybe we should rename importer_vectorization.cpp -> stringintrinsics.cpp to make it consistent with hwintrinsics.cpp?

I have a batch of changes for it support bytes - not sure it can be called stringintrinsics after that.

@EgorBo
Copy link
Member

EgorBo commented Oct 9, 2022

And honestly, I hate hwintrinsics.cpp its name doesn't tell if it's Importer-phase related code or codegen or lower 🙂

@jakobbotsch
Copy link
Member Author

How about I just rename importer_vectorization.cpp -> importervectorization.cpp, importcall.cpp -> importercalls.cpp and register_arg_convention -> registerargconvention?

@EgorBo
Copy link
Member

EgorBo commented Oct 9, 2022

How about I just rename importer_vectorization.cpp -> importervectorization.cpp, importcall.cpp -> importercalls.cpp and register_arg_convention -> registerargconvention?

Works for me (although I'd prefer capital letters but it's against our guidelines for file names I assume) 👍 maybe someone from @dotnet/jit-contrib have a different opinion?

@jakobbotsch jakobbotsch changed the title JIT: Split out call importation into new importcall.cpp JIT: Split out call importation into new importercalls.cpp Oct 9, 2022
@jakobbotsch
Copy link
Member Author

This change shows some differences in diff algorithms:

❯ git diff 79a78728bd40ae917^..79a78728bd40ae917 --diff-algorithm=myers --shortstat -- .\src\coreclr\jit\importer.cpp
 1 file changed, 8765 insertions(+), 16568 deletions(-)
❯ git diff 79a78728bd40ae917^..79a78728bd40ae917 --diff-algorithm=histogram --shortstat -- .\src\coreclr\jit\importer.cpp
 1 file changed, 7803 deletions(-)

Unfortunately I'm not sure if Git today supports using a different diff algorithm than Myers for git blame/git log -L.

@am11
Copy link
Member

am11 commented Oct 9, 2022

A typical way to retain history is to keep the rename and code change commits separate, and merge the PR without squashing (or split file renames into a separate PR).

@jakobbotsch
Copy link
Member Author

A typical way to retain history is to keep the rename and code change commits separate, and merge the PR without squashing (or split file renames into a separate PR).

I am not just renaming a file here, I am splitting importer.cpp into importer.cpp and importercalls.cpp. There are no code changes, the problem is that Git's default diff algorithm does not realize that I am just deleting code in importer.cpp and for some reason thinks I am changing the deleted functions into differently named functions from later in the file.

I tried splitting the delete in two commits where the first commit left all comments as sort of "anchors" and the second commit then deleted all the comments. Indeed this would then have to be rebased in. Unfortunately the same problem just happens in the second commit, with Git's default diff algorithm believing I am changing the comments I am deleting into code from later in the file.

@jakobbotsch
Copy link
Member Author

I'm trying now to see if I can do the move in a few chunks instead to convince the diff algorithm so that git blame/git log -L will continue working properly (on at least the remaining importer code, and hopefully on the moved code too with some of the args meant for that).

@jakobbotsch jakobbotsch force-pushed the split-out-call-importation branch 2 times, most recently from 0e8a89a to 947ab2c Compare October 9, 2022 18:58
@tannergooding
Copy link
Member

tannergooding commented Oct 9, 2022

@jakobbotsch, feel free to rename (or log an issue tracking a rename for) hwintrinsic.cpp to importhwintrinsic.cpp as well.

We might want to decide how to do cases like hwintrinsiccodegenxarch.cpp in that it could be either codegenxarchhwintrinsic.cpp or codegenhwintrinsicxarch.cpp.

Also just noting, as names get longer like this, I think that the _ might help with readability and discoverability of files. Not a huge preference, just noting that since its all lower codegenxarchhwintrinsic is harder to read than codegen_xarch_hwintrinsic.cpp

@jakobbotsch
Copy link
Member Author

hwintrinsic.cpp does seem to have some functions that are not related to importation, e.g. Compiler::vnEncodesResultTypeForHWIntrinsic. I think I'll leave it as is for now, we can do follow-up changes if we want to make things more consistent or change the file name conventions.

@jakobbotsch
Copy link
Member Author

Ok, moving the functions in batches seems to have worked out, Git properly tracks the deletions in the individual commits. Now we'll just need to rebase/merge this PR.

@AndyAyersMS
Copy link
Member

Ok, moving the functions in batches seems to have worked out, Git properly tracks the deletions in the individual commits. Now we'll just need to rebase/merge this PR.

Are you planning on not squashing this?

I have some edits for impCheckCanInline in a local branch, will be interesting to see if they can make it into the new location. When I split up flowgraph.cpp it was one big commit and git could not figure out what went where.

@AndyAyersMS
Copy link
Member

I suppose I can pull down your changes and rebase what I have on top of that.

@jakobbotsch
Copy link
Member Author

Are you planning on not squashing this?

I have some edits for impCheckCanInline in a local branch, will be interesting to see if they can make it into the new location. When I split up flowgraph.cpp it was one big commit and git could not figure out what went where.

Yes, that would be the plan. But I don't think Git can figure the code move out automatically, unfortunately.
But at least Git is not going to think I touched the remaining parts of the importer in this PR.

…m file names

Also avoid marking some functions as 'inline' since then they cannot be
used from other TUs (in general, we can just leave the DCE up to the
compiler).
…atibleMethodGDV, considerGuardedDevirtualization, addGuardedDevirtualizationCandidate
…getIntrinsic, IsIntrinsicImplementedByUserCall, IsMathIntrinsic, impDevirtualizeCall, impConsiderCallProbe, compClassifyGDVProbeType, impGetSpecialIntrinsicExactReturnType
…Intrinsic, impArrayAccessIntrinsic, impKeepAliveIntrinsic
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib, any final thoughts?

@stephentoub stephentoub merged commit d6fdb3a into dotnet:main Oct 10, 2022
@jakobbotsch jakobbotsch deleted the split-out-call-importation branch October 10, 2022 21:54
@stephentoub
Copy link
Member

rebased and merged per @jakobbotsch's request

@ghost ghost locked as resolved and limited conversation to collaborators Nov 10, 2022
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.

6 participants