• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SamboyCoding / Cpp2IL / 17101091060

20 Aug 2025 02:16PM UTC coverage: 30.421% (-3.9%) from 34.352%
17101091060

Pull #481

github

web-flow
Merge 42542dde2 into d5260685f
Pull Request #481: Decompiler

1804 of 7551 branches covered (23.89%)

Branch coverage included in aggregate %.

102 of 1827 new or added lines in 35 files covered. (5.58%)

40 existing lines in 6 files now uncovered.

4095 of 11840 relevant lines covered (34.59%)

165714.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Cpp2IL.Core/Actions/RemoveSsaForm.cs
1
using System.Collections.Generic;
2
using System.Linq;
3
using Cpp2IL.Core.ISIL;
4
using Cpp2IL.Core.Model.Contexts;
5

6
namespace Cpp2IL.Core.Actions;
7

8
public class RemoveSsaForm : IAction
9
{
10
    public void Apply(MethodAnalysisContext method)
11
    {
NEW
12
        var cfg = method.ControlFlowGraph!;
×
13

NEW
14
        foreach (var block in cfg.Blocks)
×
15
        {
16
            // Get all phis
NEW
17
            var phiInstructions = block.Instructions
×
NEW
18
                .Where(i => i.OpCode == OpCode.Phi)
×
NEW
19
                .ToList();
×
20

NEW
21
            if (phiInstructions.Count == 0) continue;
×
22

NEW
23
            foreach (var predecessor in block.Predecessors)
×
24
            {
NEW
25
                if (predecessor.Instructions.Count == 0)
×
26
                    continue;
27

NEW
28
                predecessor.Instructions.RemoveAt(0);
×
NEW
29
                var moves = new List<Instruction>();
×
30

NEW
31
                foreach (var phi in phiInstructions)
×
32
                {
NEW
33
                    var result = (LocalVariable)phi.Operands[0]!;
×
NEW
34
                    var sources = phi.Operands.Skip(1).Cast<LocalVariable>().ToList();
×
35

NEW
36
                    var predIndex = block.Predecessors.IndexOf(predecessor);
×
37

NEW
38
                    if (predIndex < 0 || predIndex >= sources.Count)
×
39
                        continue;
40

NEW
41
                    var source = sources[predIndex];
×
42

43
                    // Add move for it
NEW
44
                    moves.Add(new Instruction(-1, OpCode.Move, result, source));
×
45
                }
46

47
                // Add all of those moves
NEW
48
                if (predecessor.Instructions.Count == 0)
×
NEW
49
                    predecessor.Instructions = moves;
×
50
                else
NEW
51
                    predecessor.Instructions.InsertRange(predecessor.Instructions.Count - (predecessor.Instructions.Count == 1 ? 1 : 2), moves);
×
52
            }
53

54
            // Remove all phis
NEW
55
            foreach (var instruction in block.Instructions)
×
56
            {
NEW
57
                if (instruction.OpCode == OpCode.Phi)
×
58
                {
NEW
59
                    instruction.OpCode = OpCode.Nop;
×
NEW
60
                    instruction.Operands = [];
×
61
                }
62
            }
63
        }
64

NEW
65
        cfg.RemoveNops();
×
NEW
66
        cfg.RemoveEmptyBlocks();
×
NEW
67
    }
×
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc