26 Commits
Author SHA1 Message Date
Siegfried Pammer e1ca4db851 Fix #2527: Support skip locals init 2021-10-29 00:16:33 +02:00
Daniel Grunwald c26d9ad6f1 Mark stack slot for aggressive removal in InfeasiblePathTransform
This helps with pattern matching in short circuiting operators.
2021-07-18 23:34:29 +02:00
Siegfried Pammer c22977e1be Fix #2390: Extend variable splitting to treat stobj as immediate address use. 2021-06-04 19:53:09 +02:00
dotnet format 0d9f871a4f #2128: Reformat the whole code base. 2020-08-28 01:05:38 +02:00
Daniel Grunwald 060830dd64 Variable splitting: support cases where a ref is passed through a ref-returning method, and then used.
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.
2020-04-19 11:08:31 +02:00
Siegfried Pammer 1e3e8fdac1 Allow ref-locals to be initialized from nested field addresses. 2019-07-30 00:44:05 +02:00
Daniel Grunwald 47ca51a769 Clarify the meaning of ILVariable.Index 2019-02-15 11:42:16 +01:00
Siegfried Pammer 1dcae5bff8 Extend HandleCall to NewObj instructions as well. 2018-08-10 22:57:47 +02:00
Siegfried Pammer b701bed2ff SplitVariables: analyze address usage in virtual calls as well. Treat them the same as call instructions. 2018-08-10 13:06:44 +02:00
Daniel Grunwald 7ee686cb67 Allow splitting a variable even if it has its address taken and stored in a ref-local.
The currently implementation is somewhat minimal and only works in a very limited set of circumstances:
 * the ref local is single-assignment
 * the ref local is initialized directly with 'ldloca target; stloc ref_local',
     not a derived pointer (e.g. 'ldloca target; ldflda F; stloc ref_local').
 * all uses of the ref_local are immediately consuming the address

This improves variable splitting cases where the compiler re-uses a stack slot containing a reference,
e.g. in some cases of '?.' on Nullable<T>.
2018-07-14 00:37:02 +02:00
Daniel Grunwald d166101387 Allow splitting variables that have their address taken.
This works if all addresses are immediately used in calls (as common with method calls on value-type,
which take 'this' by-reference); as long as the call doesn't return the reference again.

Closes #1136.
2018-07-13 21:12:15 +02:00
Daniel Grunwald b149238777 Introduce IType.IsByRefLike. 2018-07-13 21:01:33 +02:00
Daniel Grunwald 6d8d37f8fc Add ValueTypeCall foreach testcase. 2017-11-04 19:05:51 +01:00
Daniel Grunwald df27dc9686 Fix NullReferenceException in SplitVariables.AddressUsedOnlyForReading 2017-09-15 19:46:57 +02:00
Daniel Grunwald f5d907e0ce [async] Allow splitting awaiter variables. 2017-09-11 23:32:29 +02:00
Daniel Grunwald 5c4a87eb32 Variable splitting for variables of type Nullable<T>. 2017-08-29 23:27:02 +02:00
Siegfried Pammer 074aa45acf Add HasGeneratedName flag 2017-08-27 19:06:10 +02:00
Daniel Grunwald 2207ab40f7 Check the CancellationToken a bit more frequently. 2017-08-22 22:24:16 +02:00
Daniel Grunwald bddda342a1 Improve yield-return-decompiler. 2017-08-19 19:13:37 +02:00
Siegfried Pammer 0970b95d5f Rename ILVariable.Scope to Function and introduce BlockContainer CaptureScope 2016-12-18 14:08:10 +01:00
Siegfried Pammer 840ec04fde Namespace adjustments for Syntax classes 2016-11-26 12:06:58 +01:00
Christoph Wille 1ce8349dd9 Adjust namespaces 2016-11-26 11:12:53 +01:00
Daniel Grunwald 275a147224 First attempt at pinned regions. 2016-06-26 23:05:11 +02:00
Daniel Grunwald f3d108c469 Add SplitVariables transforms. 2016-06-20 23:01:41 +02:00
Daniel Grunwald f5e66ff623 Extract reusable DataFlowVisitor from ReachingDefinitions; and add ILVariable.HasInitialValue. 2016-06-18 02:45:53 +02:00
Daniel Grunwald b55775e2cc Add reaching definitions analysis. 2016-06-16 00:35:55 +02:00