Coverage Report

Created: 2026-10-26 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/solidity/libyul/backends/evm/ssa/analysis/ReducibilityCheck.cpp
Line
Count
Source
1
/*
2
  This file is part of solidity.
3
4
  solidity is free software: you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation, either version 3 of the License, or
7
  (at your option) any later version.
8
9
  solidity is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
14
  You should have received a copy of the GNU General Public License
15
  along with solidity.  If not, see <http://www.gnu.org/licenses/>.
16
*/
17
// SPDX-License-Identifier: GPL-3.0
18
19
#include <libyul/backends/evm/ssa/analysis/ReducibilityCheck.h>
20
21
#include <libyul/backends/evm/ssa/analysis/DepthFirstSpanningTree.h>
22
#include <libyul/backends/evm/ssa/analysis/DominatorTree.h>
23
24
using namespace solidity::yul::ssa;
25
using namespace solidity::yul::ssa::analysis;
26
27
bool analysis::isReducibleCFG(DepthFirstSpanningTree const& _dfsTree)
28
0
{
29
0
  DominatorTree const dominatorTree(_dfsTree);
30
0
  for (auto const src: _dfsTree.preOrder())
31
0
  {
32
0
    bool reducible = true;
33
0
    _dfsTree.cfg().block(src).forEachExit([&](SSACFG::BlockId const& _target) {
34
0
      if (
35
0
        _dfsTree.ancestor(_target, src) &&
36
0
        !dominatorTree.dominates(_target, src)
37
0
      )
38
0
        reducible = false;
39
0
    });
40
0
    if (!reducible)
41
0
      return false;
42
0
  }
43
0
  return true;
44
0
}