mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
From `IndexRangeTest.UseIndexForRef`: ``` stloc V_4(call GetSpan()) stloc S_19(ldloca V_4) stloc V_2(call get_Length(ldloc S_19)) stloc V_3(call GetOffset(addressof System.Index(call GetIndex(ldc.i4 0)), ldloc V_2)) call UseRef(call get_Item(ldloc S_19, ldloc V_3)) stloc V_4(call GetSpan()) stloc S_30(ldloca V_4) stloc V_2(binary.sub.i4(call get_Length(ldloc S_30), call GetInt(ldc.i4 0))) call UseRef(call get_Item(ldloc S_30, ldloc V_2)) ``` Due to `Span.get_Item` being a ref-return, it's possible that `ref V_4` is returned and passed into the `UseRef` method (this can't actually happen given Span's implementation, but it's a possible implementation of the get_Item type signature). But we still need to split `V_4` -- it's a compiler-generated variable and needs to be inlined. I think we can do this relatively simply by continuing to go up the ancestor instructions when we hit a ref-returning call. The recursive `DetermineAddressUse` call will check that there are no stores to `V_4` between the `get_Item` call and the point where the returned reference is used. Thus we still ensure that we don't split a variable while there is a live reference to it.pull/1986/head
1 changed files with 7 additions and 8 deletions
Loading…
Reference in new issue