40 Commits
Author SHA1 Message Date
dotnet format 0d9f871a4f #2128: Reformat the whole code base. 2020-08-28 01:05:38 +02:00
Daniel Grunwald fc51dd17a5 Remove outdated comment. The PickExitPoint heuristic is no longer using "amount of code" but the IL block order. 2020-07-25 15:53:13 +02:00
Daniel Grunwald c647016bfb #2070: Allow PickExitPoint heuristic to choose a return;/yield break; that is part of a condition block. 2020-07-22 23:02:42 +02:00
Jane Doe 446ac06e38 candiate -> candidate 2019-10-13 07:49:22 -07:00
Daniel Grunwald c4cb9df687 Fix switch in loops sometimes detecting an invalid switch body. 2019-07-26 17:14:12 +02:00
Daniel Grunwald 8117dfff4a Fix #1242: Discard unreachable code.
Unreachable code is not part of the dominator tree, which most of our transforms are based on.

In particular, dominance-based loop detection runs into the problem where unreachable code might have jumps into two independent loops. In that case, it's impossible to place the unreachable code in a way that avoids assertions / generating invalid C#.

We establish the invariant that all blocks in a BlockContainer must be statically reachable from the entry point (-> every block is part of the dominator tree). This means transforms no longer have to deal with special cases for unreachable code.

The "Remove dead and side effect free code" option still has an effect on dead stores, but unreachable code is now always removed (previously this also was dependent on this option).
2019-07-26 17:14:12 +02:00
Daniel Grunwald ccdabf2325 Fix a bunch of XmlDoc compiler warnings. 2019-07-17 19:15:43 +02:00
Siegfried Pammer 29527b804e Fix #1392: LoopDetection should take switch block containers into account in IncludeNestedContainers. 2019-02-16 22:29:13 +01:00
Siegfried Pammer c1fca21e8a Make ILRange field private - introduce public API for IL range manipulation. 2019-02-16 20:36:17 +01:00
Chicken-Bones e9b766d708 Improve persistence of IL offsets through various transforms. 2018-10-08 21:21:55 +10:00
Chicken-Bones d8244e347b Select outer-loop continue branches as break targets for switches in nested loops 2018-08-14 11:21:21 +10:00
Chicken-Bones 7017d998d0 Improve switch decompilation in loops via early detection of continue blocks. 2018-08-14 11:21:17 +10:00
Daniel Grunwald 542e088ceb Fix #1185: assertion with unreachable code in loop detection 2018-07-29 11:13:43 +02:00
Daniel Grunwald c16817ab4e Fix #1186: LoopDetection assertion with unreachable code 2018-07-29 11:13:39 +02:00
Siegfried Pammer 61fd48b4a4 Merge branch 'master' of github.com:icsharpcode/ILSpy into loops 2017-11-07 22:27:18 +01:00
Daniel Grunwald d6bc1ca762 #915: Fix LoopDetection.FindExitPoint() incorrectly returning null (=multiple exit points; use heuristic) when there was only a single exit point that wasn't dominated by the loop head. 2017-11-06 21:32:19 +01:00
Siegfried Pammer 2432c43880 Merge branch 'master' of github.com:icsharpcode/ILSpy into loops
# Conflicts:
#	ICSharpCode.Decompiler/IL/ILReader.cs
2017-11-06 17:52:39 +01:00
Daniel Grunwald e6afe4bf98 Fix #915: ensure that loops are nested correctly 2017-11-05 19:58:57 +01:00
Siegfried Pammer 28113f7f1e Merge branch 'master' of github.com:icsharpcode/ILSpy into loops 2017-11-05 16:26:15 +01:00
Daniel Grunwald 7af15d27cd Fix #905: improve exit point detection for foreach loops. 2017-11-05 00:44:32 +01:00
Siegfried Pammer 154833b06c Add ContainerKind 2017-11-05 00:41:10 +01:00
Siegfried Pammer 12e39cf63c Fix switch exit points. 2017-10-12 23:14:01 +02:00
Daniel Grunwald 953c6a0929 Keep code dominated by a single switch section within the switch. 2017-10-11 21:41:11 +02:00
Daniel Grunwald de2c647114 Revert "Fix bug that could cause nodes reachable from the exit point to be moved into the loop/switch."
This reverts commit 105ff744b3.

A correctly chosen single exit point should dominate all other code that
is dominated by the loop but not included in the body -- otherwise there
would be multiple exit points.
So this "bugfix" was only covering up for us not properly validating the
exit points from post-dominance.
2017-10-11 20:53:58 +02:00
Daniel Grunwald cd993ad074 Property validate exit points determined using post-dominance. 2017-10-11 20:53:57 +02:00
Daniel Grunwald 9ef97703cd [switch] consider loop back-edges to be exit points when looking for the switch body 2017-10-11 19:43:34 +02:00
Daniel Grunwald 105ff744b3 Fix bug that could cause nodes reachable from the exit point to be moved into the loop/switch. 2017-10-08 23:55:08 +02:00
Daniel Grunwald 102729cfde Put switch instructions into their own BlockContainer.
This removes the need for "goto case" in the ILAst as we can just branch to the appropriate block.
It also means we can support "break;" within switch using the "leave" instruction (otherwise we'd have to introduce yet another special kind of jump).
2017-10-08 23:06:38 +02:00
Daniel Grunwald a6c6ddcea1 Fix #861: Improved loop exit point heuristic. 2017-09-27 23:43:06 +02:00
Daniel Grunwald fe84ea9730 WIP: yield return decompiler 2016-12-20 21:55:28 +01:00
Daniel Grunwald 66dee6c6f9 LoopDetection: find appropriate exit points 2016-11-27 18:20:17 +01:00
Daniel Grunwald e871f7c05a Convert LoopDetection into a block transform. 2016-11-27 18:00:54 +01:00
Daniel Grunwald ed3d4aba9d Run IntroduceExitPoints before loop detection, and let loop detection introduce its own exit points.
Warning: this commit creates broken branches that enter blocks.
2016-11-27 15:25:22 +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 9dec6c80a7 LoopDetection: use post-dominance to find better loop exit points 2016-07-29 15:35:35 +02:00
Daniel Grunwald 0e118f0977 LoopDetection: in loops without any exit points, exclude the largest possible code block from the loop 2016-07-28 21:26:12 +02:00
Daniel Grunwald 449bbe2043 Move transforms to transforms namespace 2016-07-10 13:58:40 +02:00
Daniel Grunwald b10feca78b Add 'InlineCompilerGeneratedVariables' transform, hopefully this is sufficient to replace the 'variable splitting' in the old decompiler. 2015-06-14 22:05:19 +02:00
Daniel Grunwald 2509f27223 * Rename ControlFlowSimplification to ConditionDetection
* Rename OptimizingTransform to ControlFlowSimplification
* Move control flow transforms to separate namespace.
2015-06-14 20:53:22 +02:00