Daniel Grunwald
503048b314
Prevent the early ILInlining pass from creating `addressof` instructions
3 years ago
Daniel Grunwald
3c847b56a2
Fix decompilation of async streams compiled with Roslyn 4.2
3 years ago
Siegfried Pammer
4c1931d5c6
Fix NRT warning in GetBlockStateSetMappingForLeave.
3 years ago
Siegfried Pammer
a4e2bd7f8f
Handle leave instructions in state-range analysis.
3 years ago
Siegfried Pammer
84c15bb24f
Fix #2652 : AwaitInFinallyTransform: ILAst must form a tree
3 years ago
Siegfried Pammer
3c2e52854e
DetectPinnedRegions: Inline the stack-slot involved in CustomRefPinPattern so that the following ProcessPinnedRegion call can reuse existing unmanaged pointer variables instead of being forced to create a new variable.
3 years ago
Siegfried Pammer
f98012ec16
DetectPinnedRegions: Support special case where pinned pointer is unused and the compiler optimized out the StopGCTracking-conversion.
3 years ago
Daniel Grunwald
787621fb51
Revert "Use Nop instead of InvalidExpression to hold the "goto from catch-block to try-block" comment"
...
This reverts commit 77dcbbee86
.
4 years ago
Daniel Grunwald
cedd8a6bf6
Fix #2480 : Avoid yield-return decompilation if there are unrecognized state assignments in a finally method.
4 years ago
Daniel Grunwald
77dcbbee86
Use Nop instead of InvalidExpression to hold the "goto from catch-block to try-block" comment
4 years ago
Siegfried Pammer
1826ac031d
#2539 : Add support for yield state machine pattern used by mcs 5.x
4 years ago
Daniel Grunwald
df339e72fb
Fix DetectPinnedRegions.SplitBlocksAtWritesToPinnedLocals creating blocks without ILRange.
...
These blocks could trigger assertions if LoopDetection was creating a loop BlockContainer from them (BlockContainers have an assertion requiring an ILRange).
Closes #2533 and #2457 .
4 years ago
Daniel Grunwald
583771e012
#2533 : Fix bug in CreatePinnedRegion that could cause pinned regions to be created with the wrong entry point if the original IL had blocks in an unusual order
4 years ago
Siegfried Pammer
e1ca4db851
Fix #2527 : Support skip locals init
4 years ago
Siegfried Pammer
9d99ee86db
Fix #2503 : Move correct branch in the case of swapped jump-table conditions.
4 years ago
Daniel Grunwald
109b6d073a
Allow detecting exit points across multiple levels of containers.
4 years ago
Daniel Grunwald
a716828065
Remove redundant code from RemoveRedundantReturn.cs
4 years ago
Daniel Grunwald
685a79dc31
DetectExitPoints: introduce exit points for loops+switch
...
This allows reverting the changes to HighLevelLoopTransform+ReduceNestingTransform from the previous commit, which fixes a bug in loop detection (the previous commit did not handle loops where the loop BlockContainer didn't have a Block as parent).
4 years ago
Daniel Grunwald
6757295b3b
Fix #2379 : Keep `return` statements around in original form for ConditionDetection, only transform to fall-through block-exit at the end of the transform pipeline.
...
This fixes an issue where `return` statements within try-blocks could turn into `goto` statements.
4 years ago
Daniel Grunwald
407ec6be5b
Adjust AsyncAwaitDecompiler to Roslyn 3.9.0.
4 years ago
Siegfried Pammer
7211587b45
Fix #2366 : NRE in AwaitInCatchTransform.MatchAwaitCatchHandler() and pattern errors when dealing with a switch-based jump table in AwaitInCatchTransform
4 years ago
Siegfried Pammer
76227af89d
Fix #1749 , fix #2339 , fix #2353 : Add support for rethrow in async exception handlers, fix await catch/finally patterns for complex methods.
4 years ago
Daniel Grunwald
eec24ee6bb
Fix #2311 : Handle additional `comp` instruction in `IsNullSafeArrayToPointerNotNullBlock`
4 years ago
Daniel Grunwald
0e1c24464f
Fix #2148 : Don't attempt to detect `fixed` statement for pinned value types
5 years ago
Daniel Grunwald
3d10509b1b
Add SparseIntegerSwitch option.
5 years ago
Daniel Grunwald
b035ec1960
Fix #2129 : be more flexible about the initialization order for the async state machine.
5 years ago
dotnet format
0d9f871a4f
#2128 : Reformat the whole code base.
5 years ago
Siegfried Pammer
a6bbccae8d
Fix #2123 : switch on string detection:
...
1) Do not remove switchValueVar, if it is used elsewhere.
2) Support empty case blocks in SimplifyCascadingIfStatements transform
5 years ago
Daniel Grunwald
f5409ebe31
Fix re-pinning getting confused about which variant of the pinned local to use when the new re-pinned reference depends on the old pinned reference.
5 years ago
Daniel Grunwald
4b716e2db5
Fix #2056 : "remove branch into body" must be executed before the clone cleanup
...
Otherwise the to-be-removed branch could keep an soon-to-be-unreachable block alive outside the pinned region.
5 years ago
Daniel Grunwald
bd4e565b93
Ensure all pinned regions variables are converted to VariableKind.PinnedRegionLocal
5 years ago
Daniel Grunwald
ddff831cf0
#1292 : Fix some more problems with pinned locals.
...
Let's distinguish between the original pinned locals and the PinnedRegion locals.
The format need declarations if any are left over after transformations; the latter don't.
5 years ago
Daniel Grunwald
5bd47c171f
Don't require a definition for the task builder type, also accept an UnknownType.
5 years ago
Daniel Grunwald
fc51dd17a5
Remove outdated comment. The `PickExitPoint` heuristic is no longer using "amount of code" but the IL block order.
5 years ago
Daniel Grunwald
c647016bfb
#2070 : Allow `PickExitPoint` heuristic to choose a `return;`/`yield break;` that is part of a condition block.
5 years ago
Daniel Grunwald
2acc4339df
#2058 : Mark most transforms as public to help users that use the ILAst directly without decompiling to C#.
5 years ago
Daniel Grunwald
417a2c3391
Revert the InvertIf change; it causes too many issues for the following transforms.
5 years ago
Daniel Grunwald
e083d43fb9
Fix ReduceNestingTransform
5 years ago
Daniel Grunwald
696fdca923
Always create a block when inverting an if.
...
This keeps the ILAst more uniform and ensures extraction is possible for the code in the then statement.
5 years ago
Daniel Grunwald
d8e837ef47
Fix #1772 : Support EnumeratorCancellationAttribute
...
With this change, the async decompiler no longer gets confused by the logic disposing `this.<>x__combinedTokens`.
5 years ago
Daniel Grunwald
1f2d1660c8
#2023 : If blocks are reachable both from within the pinned region and from outside it, clone those blocks.
...
This removes an error condition where pinned variables could remain after DetectPinnedRegions, resulting in invalid C#.
The downside is that it's possible for the code size to increase exponentially when given sufficiently evil IL code.
5 years ago
Daniel Grunwald
30da0b7525
Add some missing checks to MatchRoslynSwitchOnString
5 years ago
Daniel Grunwald
4f4ca482be
Fix #1950 : Fix crash when finallyMethod cannot be found.
...
This seems to be possible due to a C# compiler bug.
5 years ago
Daniel Grunwald
9659be0d55
#1946 : Fix IsBranchToReturnBlock() [was broken in c1265ad830
]
5 years ago
Daniel Grunwald
c1265ad830
Fix #1946 : Don't move `return` into `try` block when doing so changes the semantics of a `finally` block.
5 years ago
Daniel Grunwald
2da513eb24
Fix #1988 : handle Roslyn 3.6 task creation pattern in async/await decompiler.
...
Roslyn 3.6 no longer makes a redundant copy of the `AsyncTaskMethodBuilder`, but directly calls `stateMachine.<>t__builder.Start(ref stateMachine);`
5 years ago
Siegfried Pammer
8925b4ff7b
Inline variable declarations/modernize parts of our code base.
5 years ago
Jackson Davis
6ab1f98fa3
Expand the range of sequence points out the closest empty ilstack
...
or implicit sequence point without creating overlapping sequence points.
If such a location cannot be found do, nothing. Fill in the
gaps with hidden sequence points.
Also emit a sequence point for
the prolog to account for seqeunce point there emitted by the C#
compiler. Without this, the debugger can stop there on a step in
using the original pdb, then decompile resulting in a no-code at this
location failure.
5 years ago
Daniel Grunwald
65fe59e393
#1918 : Fix a bunch of issues with pinned region detection.
...
Not every pinned region has a clean `P = null` assignment to mark its end.
If a second pinned region starts with the same variable `P`, consider that to mark the end of the previous pinned region for that variable.
Also, fix a bunch of special cases with empty pinned regions.
5 years ago
Siegfried Pammer
413c5b3baf
PortablePdbWriter: Add primitive support for state-machine hoisted local scopes. All variables are visible in the whole MoveNext method.
5 years ago