/src/solidity/libyul/optimiser/EquivalentFunctionCombiner.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 | | * Optimiser component that combines syntactically equivalent functions. |
20 | | */ |
21 | | |
22 | | #include <libyul/optimiser/EquivalentFunctionCombiner.h> |
23 | | #include <libyul/AST.h> |
24 | | #include <libsolutil/CommonData.h> |
25 | | |
26 | | using namespace std; |
27 | | using namespace solidity; |
28 | | using namespace solidity::yul; |
29 | | |
30 | | void EquivalentFunctionCombiner::run(OptimiserStepContext&, Block& _ast) |
31 | 46.9k | { |
32 | 46.9k | EquivalentFunctionCombiner{EquivalentFunctionDetector::run(_ast)}(_ast); |
33 | 46.9k | } |
34 | | |
35 | | void EquivalentFunctionCombiner::operator()(FunctionCall& _funCall) |
36 | 916k | { |
37 | 916k | auto it = m_duplicates.find(_funCall.functionName.name); |
38 | 916k | if (it != m_duplicates.end()) |
39 | 13.8k | _funCall.functionName.name = it->second->name; |
40 | 916k | ASTModifier::operator()(_funCall); |
41 | 916k | } |