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

Fix dump of GC vars at call sites #45815

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

BruceForstall
Copy link
Member

GC vars are handled specially at call sites. In particular,
kills happen at the call site address, meaning before the
call. They JIT dump was displaying the kill after the call,
which is confusing, and different from all the other cases
of displaying GC refs. Fix this so the kills are properly
displayed before the call site.

Example diff:

call     System.Collections.Immutable.ImmutableArray:ToImmutableArray(System.Collections.Generic.IEnumerable`1[__Canon]):System.Collections.Immutable.ImmutableArray`1[__Canon]
    ; gcrRegs -[rdx r14]
    ; GC ptr vars -{V21}
    ; gcr arg pop 0

=>

    ; GC ptr vars -{V21}
call     System.Collections.Immutable.ImmutableArray:ToImmutableArray(System.Collections.Generic.IEnumerable`1[__Canon]):System.Collections.Immutable.ImmutableArray`1[__Canon]
    ; gcrRegs -[rdx r14]
    ; gcr arg pop 0

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 9, 2020
@BruceForstall
Copy link
Member Author

@dotnet/jit-contrib

I need to merge to the post-src-removal change.

Copy link
Contributor

@sandreenko sandreenko left a comment

Choose a reason for hiding this comment

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

LGTM.
I was not sure so I checked how Allocating Registers is showing it, it actually shows that the local var is dying before the call and then we have a live fixedReg interval for the register

DefList: {  }
N031 (  3,  2) [000007] ------------              *  LCL_VAR   int    V01 loc0         u:3 NA (last use) REG NA $140

DefList: {  }
N033 (???,???) [000025] ------------              *  PUTARG_REG int    REG rcx
<RefPosition #7   @33  RefTypeFixedReg <Reg:rcx>  BB03 regmask=[rcx] minReg=1>
<RefPosition #8   @33  RefTypeUse <Ivl:1 V01> LCL_VAR BB03 regmask=[rcx] minReg=1 last fixed> <- last use for V01, it is dead after it, happens before the call
Interval  2: int RefPositions {} physReg:NA Preferences=[allInt]
<RefPosition #9   @34  RefTypeFixedReg <Reg:rcx>  BB03 regmask=[rcx] minReg=1>
<RefPosition #10  @34  RefTypeDef <Ivl:2> PUTARG_REG BB03 regmask=[rcx] minReg=1 fixed>

DefList: { N033.t25. PUTARG_REG }
N035 ( 17,  8) [000008] --CXG-------              *  CALL      void   UnitTest1.DoSomething REG NA $VN.Void
<RefPosition #11  @35  RefTypeFixedReg <Reg:rcx>  BB03 regmask=[rcx] minReg=1>
<RefPosition #12  @35  RefTypeUse <Ivl:2>  BB03 regmask=[rcx] minReg=1 last fixed>
33.#8  V1   Use *  Copy  rcx  |V1 a|V1 a|    |    |    |    |    |    |    | <- V1 is dead now
34.#9  rcx  Fixd   Keep  rcx  |    |    |    |    |    |    |    |    |    |
34.#10 I2   Def    Alloc rcx  |    |I2 a|    |    |    |    |    |    |    |
35.#11 rcx  Fixd   Keep  rcx  |    |I2 a|    |    |    |    |    |    |    | <- first call refPosition
35.#12 I2   Use *  Keep  rcx  |    |I2 a|    |    |    |    |    |    |    |

so it makes sense to show it dying before the call.

@BruceForstall
Copy link
Member Author

fwiw, SOS !u -gcinfo also shows it dying before the call

@benaadams
Copy link
Member

benaadams commented Dec 9, 2020

Needs git rebase upstream/master rebasing for the additional /src/ removal in path

GC vars are handled specially at call sites. In particular,
kills happen at the call site address, meaning before the
call. They JIT dump was displaying the kill after the call,
which is confusing, and different from all the other cases
of displaying GC refs. Fix this so the kills are properly
displayed before the call site.

Example diff:
```
call     System.Collections.Immutable.ImmutableArray:ToImmutableArray(System.Collections.Generic.IEnumerable`1[__Canon]):System.Collections.Immutable.ImmutableArray`1[__Canon]
    ; gcrRegs -[rdx r14]
    ; GC ptr vars -{V21}
    ; gcr arg pop 0

=>

    ; GC ptr vars -{V21}
call     System.Collections.Immutable.ImmutableArray:ToImmutableArray(System.Collections.Generic.IEnumerable`1[__Canon]):System.Collections.Immutable.ImmutableArray`1[__Canon]
    ; gcrRegs -[rdx r14]
    ; gcr arg pop 0

```
@BruceForstall BruceForstall merged commit d731112 into dotnet:master Dec 10, 2020
@BruceForstall BruceForstall deleted the FixGCVarsDump branch December 10, 2020 00:17
@ghost ghost locked as resolved and limited conversation to collaborators Jan 9, 2021
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.

5 participants