Skip to content

Extending variable live ranges in more cases - #77439

Closed
BrianBohe wants to merge 3 commits into
dotnet:mainfrom
BrianBohe:updating_variable_live_ranges_extension
Closed

Extending variable live ranges in more cases#77439
BrianBohe wants to merge 3 commits into
dotnet:mainfrom
BrianBohe:updating_variable_live_ranges_extension

Conversation

@BrianBohe

Copy link
Copy Markdown
Member

While debugging Issue 47202, I found that variables can die and born again without an instruction being emitted nor the emitter moving.

Here is an example from #77289 (comment):

I found a case where a variable (V06) dies (in [000054]) at the beginning of a basic block (BB05), and becomes alive (in [000016]) before an instruction is emitter. We would want to extend the live ranges in this case:

 /--* t52 long Generating: N087 ( 10, 16) [000054] DA--------- * STORE_LCL_VAR long V06 loc5 d:3 rcx REG rcx
V06 in reg rcx is becoming live [000054]
Live regs: 00000000 {} => 00000002 {rcx}
Live vars: {} => {V06}
New debug range: first
IN000f: jmp L_M3923_BB06
Variable Live Range History Dump for BB04
V04 loc3: rdx [(G_M3923_IG03,ins#5,ofs#27), (G_M3923_IG04,ins#1,ofs#10)]
V06 loc5: rcx [(G_M3923_IG04,ins#2,ofs#13), ...]
=============== Generating BB05 [060..06B), preds={BB01} succs={BB06} flags=0x00000000.20010020: i label LIR BB05 IN (1)={V09 }
OUT(1)={ V06}
Recording Var Locations at start of BB05
V09(rcx)
Change life 0000000000000008 {V06} -> 0000000000000002 {V09}
V06 in reg rcx is becoming dead [------]
Live regs: (unchanged) 00000000 {}
V09 in reg rcx is becoming live [------]
Live regs: 00000000 {} => 00000002 {rcx}
Live regs: (unchanged) 00000002 {rcx}
GC regs: (unchanged) 00000000 {}
Byref regs: (unchanged) 00000000 {}
L_M3923_BB05:
G_M3923_IG04: ; offs=000044H, funclet=00, bbWeight=0.50, byref
Mapped BB05 to G_M3923_IG05
Label: IG05, GCvars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}
Scope info: begin block BB05, IL range [060..06B)
Added IP mapping: 0x0061 STACK_EMPTY (G_M3923_IG05,ins#0,ofs#0) label
Generating: N091 (???,???) [000093] ----------- IL_OFFSET void INLRT @ 0x061[E-] REG NA
Generating: N093 ( 1, 1) [000086] ----------- t86 = LCL_VAR long V09 cse0 u:1 rcx (last use) REG rcx <l:$100, c:$140>
/--* t86 long Generating: N095 ( 5, 4) [000016] DA--G------ * STORE_LCL_VAR long V06 loc5 d:2 rcx REG rcx
V09 in reg rcx is becoming dead [000086]
Live regs: 00000002 {rcx} => 00000000 {}
Live vars: {V09} => {}
V06 in reg rcx is becoming live [000016]
Live regs: 00000000 {} => 00000002 {rcx}
Live vars: {} => {V06}
New debug range: new var or location

When the emitter moved to the next group but has not
emitted any instruction, and the variable died and
becomes alive again, we would like to extend its range.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 25, 2022
@ghostghost assigned BrianBoheOct 25, 2022
@ghost

Copy link
Copy Markdown

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

Issue Details

While debugging Issue 47202, I found that variables can die and born again without an instruction being emitted nor the emitter moving.

Here is an example from #77289 (comment):

I found a case where a variable (V06) dies (in [000054]) at the beginning of a basic block (BB05), and becomes alive (in [000016]) before an instruction is emitter. We would want to extend the live ranges in this case:

 /--* t52 long Generating: N087 ( 10, 16) [000054] DA--------- * STORE_LCL_VAR long V06 loc5 d:3 rcx REG rcx
V06 in reg rcx is becoming live [000054]
Live regs: 00000000 {} => 00000002 {rcx}
Live vars: {} => {V06}
New debug range: first
IN000f: jmp L_M3923_BB06
Variable Live Range History Dump for BB04
V04 loc3: rdx [(G_M3923_IG03,ins#5,ofs#27), (G_M3923_IG04,ins#1,ofs#10)]
V06 loc5: rcx [(G_M3923_IG04,ins#2,ofs#13), ...]
=============== Generating BB05 [060..06B), preds={BB01} succs={BB06} flags=0x00000000.20010020: i label LIR BB05 IN (1)={V09 }
OUT(1)={ V06}
Recording Var Locations at start of BB05
V09(rcx)
Change life 0000000000000008 {V06} -> 0000000000000002 {V09}
V06 in reg rcx is becoming dead [------]
Live regs: (unchanged) 00000000 {}
V09 in reg rcx is becoming live [------]
Live regs: 00000000 {} => 00000002 {rcx}
Live regs: (unchanged) 00000002 {rcx}
GC regs: (unchanged) 00000000 {}
Byref regs: (unchanged) 00000000 {}
L_M3923_BB05:
G_M3923_IG04: ; offs=000044H, funclet=00, bbWeight=0.50, byref
Mapped BB05 to G_M3923_IG05
Label: IG05, GCvars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}
Scope info: begin block BB05, IL range [060..06B)
Added IP mapping: 0x0061 STACK_EMPTY (G_M3923_IG05,ins#0,ofs#0) label
Generating: N091 (???,???) [000093] ----------- IL_OFFSET void INLRT @ 0x061[E-] REG NA
Generating: N093 ( 1, 1) [000086] ----------- t86 = LCL_VAR long V09 cse0 u:1 rcx (last use) REG rcx <l:$100, c:$140>
/--* t86 long Generating: N095 ( 5, 4) [000016] DA--G------ * STORE_LCL_VAR long V06 loc5 d:2 rcx REG rcx
V09 in reg rcx is becoming dead [000086]
Live regs: 00000002 {rcx} => 00000000 {}
Live vars: {V09} => {}
V06 in reg rcx is becoming live [000016]
Live regs: 00000000 {} => 00000002 {rcx}
Live vars: {} => {V06}
New debug range: new var or location
Author:BrianBohe
Assignees:-
Labels:

area-CodeGen-coreclr

Milestone:-

Just to be consistent with new method objective and description.
@BrianBoheBrianBohe reopened this Oct 25, 2022
@BrianBohe

Copy link
Copy Markdown
MemberAuthor

After this PR

Variable Live Range History Dump for BB04
V04 loc3: rdx [(G_M3923_IG03,ins#8,ofs#46), (G_M3923_IG04,ins#1,ofs#10)]
V06 loc5: rcx [(G_M3923_IG04,ins#2,ofs#13), ...]
=============== Generating BB05 [060..06B), preds={BB01} succs={BB06} flags=0x00000000.20010020: i label LIR BB05 IN (1)={V09 }
OUT(1)={ V06}
Recording Var Locations at start of BB05
V09(rcx)
Change life 0000000000000008 {V06} -> 0000000000000002 {V09}
V06 in reg rcx is becoming dead [------]
Live regs: (unchanged) 00000000 {}
V09 in reg rcx is becoming live [------]
Live regs: 00000000 {} => 00000002 {rcx}
Live regs: (unchanged) 00000002 {rcx}
GC regs: (unchanged) 00000000 {}
Byref regs: (unchanged) 00000000 {}
L_M3923_BB05:
G_M3923_IG04: ; offs=000044H, funclet=00, bbWeight=0.50, byref
Mapped BB05 to G_M3923_IG05
Label: IG05, GCvars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}
Scope info: begin block BB05, IL range [060..06B)
Added IP mapping: 0x0061 STACK_EMPTY (G_M3923_IG05,ins#0,ofs#0) label
Generating: N091 (???,???) [000093] ----------- IL_OFFSET void INLRT @ 0x061[E-] REG NA
Generating: N093 ( 1, 1) [000086] ----------- t86 = LCL_VAR long V09 cse0 u:1 rcx (last use) REG rcx <l:$100, c:$140>
/--* t86 long Generating: N095 ( 5, 4) [000016] DA--G------ * STORE_LCL_VAR long V06 loc5 d:2 rcx REG rcx
V09 in reg rcx is becoming dead [000086]
Live regs: 00000002 {rcx} => 00000000 {}
Live vars: {V09} => {}
V06 in reg rcx is becoming live [000016]
Live regs: 00000000 {} => 00000002 {rcx}
Live vars: {} => {V06}
Extending debug range...
Variable Live Range History Dump for BB05
V06 loc5: rcx [(G_M3923_IG04,ins#2,ofs#13), ...]

@AndyAyersMS

Copy link
Copy Markdown
Member

I wonder if we should consider moving to a "lazy kill" mode like we do for gc tracking. That is, even if a local is no longer live, so long as the register it was in does not get modified, we can still report the local in the debug info.

@BrianBohe

Copy link
Copy Markdown
MemberAuthor

I wonder if we should consider moving to a "lazy kill" mode like we do for gc tracking. That is, even if a local is no longer live, so long as the register it was in does not get modified, we can still report the local in the debug info.

I didn't know that such a thing exists, sounds like the appropriate case. Let me read about it a little bit.

@BrianBohe
BrianBohe marked this pull request as draft November 16, 2022 23:07
@ghostghost closed this Dec 17, 2022
@ghost

Copy link
Copy Markdown

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@ghostghost locked as resolved and limited conversation to collaborators Jan 16, 2023
@BrianBohe
BrianBohe deleted the updating_variable_live_ranges_extension branch February 10, 2023 23:06
This pull request was closed.
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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

@BrianBohe@AndyAyersMS