Coverage Report

Created: 2026-07-13 07:08

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/solidity/libyul/optimiser/EquivalentFunctionCombiner.h
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
 * Optimiser component that combines syntactically equivalent functions.
20
 */
21
#pragma once
22
23
#include <libyul/optimiser/ASTWalker.h>
24
#include <libyul/optimiser/EquivalentFunctionDetector.h>
25
#include <libyul/optimiser/OptimiserStep.h>
26
#include <libyul/ASTForward.h>
27
28
namespace solidity::yul
29
{
30
31
struct OptimiserStepContext;
32
33
/**
34
 * Optimiser component that detects syntactically equivalent functions and replaces all calls to any of them by calls
35
 * to one particular of them.
36
 *
37
 * Prerequisite: Disambiguator, Function Hoister
38
 */
39
class EquivalentFunctionCombiner: public ASTModifier
40
{
41
public:
42
  static constexpr char const* name{"EquivalentFunctionCombiner"};
43
  static void run(OptimiserStepContext&, Block& _ast);
44
45
  using ASTModifier::operator();
46
  void operator()(FunctionCall& _funCall) override;
47
48
private:
49
435k
  EquivalentFunctionCombiner(std::map<YulName, FunctionDefinition const*> _duplicates): m_duplicates(std::move(_duplicates)) {}
50
  std::map<YulName, FunctionDefinition const*> m_duplicates;
51
};
52
53
54
}