diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index 0bb98e467..811a6239b 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -128,8 +128,6 @@ add_library(yul optimiser/LoadResolver.h optimiser/LoopInvariantCodeMotion.cpp optimiser/LoopInvariantCodeMotion.h - optimiser/MainFunction.cpp - optimiser/MainFunction.h optimiser/Metrics.cpp optimiser/Metrics.h optimiser/NameCollector.cpp diff --git a/libyul/optimiser/MainFunction.cpp b/libyul/optimiser/MainFunction.cpp deleted file mode 100644 index 8adabbe32..000000000 --- a/libyul/optimiser/MainFunction.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 -/** - * Changes the topmost block to be a function with a specific name ("main") which has no - * inputs nor outputs. - */ - -#include - -#include -#include - -#include - -#include - -using namespace std; -using namespace solidity; -using namespace solidity::yul; - -void MainFunction::operator()(Block& _block) -{ - assertThrow(_block.statements.size() >= 1, OptimizerException, ""); - assertThrow(holds_alternative(_block.statements[0]), OptimizerException, ""); - for (size_t i = 1; i < _block.statements.size(); ++i) - assertThrow(holds_alternative(_block.statements.at(i)), OptimizerException, ""); - /// @todo this should handle scopes properly and instead of an assertion it should rename the conflicting function - assertThrow(NameCollector(_block).names().count("main"_yulstring) == 0, OptimizerException, ""); - - Block& block = std::get(_block.statements[0]); - FunctionDefinition main{ - block.debugData, - "main"_yulstring, - {}, - {}, - std::move(block) - }; - _block.statements[0] = std::move(main); -} diff --git a/libyul/optimiser/MainFunction.h b/libyul/optimiser/MainFunction.h deleted file mode 100644 index c2f137e48..000000000 --- a/libyul/optimiser/MainFunction.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -// SPDX-License-Identifier: GPL-3.0 -/** - * Changes the topmost block to be a function with a specific name ("main") which has no - * inputs nor outputs. - */ - -#pragma once - -#include - -namespace solidity::yul -{ - -struct OptimiserStepContext; - -/** - * Prerequisites: Function Grouper - */ -class MainFunction -{ -public: - static constexpr char const* name{"MainFunction"}; - static void run(OptimiserStepContext&, Block& _ast) { MainFunction{}(_ast); } - - void operator()(Block& _block); - -private: - MainFunction() = default; -}; - -} diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index 7e2a4c959..bcf180add 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -174,11 +173,6 @@ YulOptimizerTestCommon::YulOptimizerTestCommon( FunctionGrouper::run(*m_context, *m_ast); FullInliner::run(*m_context, *m_ast); }}, - {"mainFunction", [&]() { - disambiguate(); - FunctionGrouper::run(*m_context, *m_ast); - MainFunction::run(*m_context, *m_ast); - }}, {"rematerialiser", [&]() { disambiguate(); ForLoopInitRewriter::run(*m_context, *m_ast); diff --git a/test/libyul/yulOptimizerTests/mainFunction/empty_block.yul b/test/libyul/yulOptimizerTests/mainFunction/empty_block.yul deleted file mode 100644 index 635e618d5..000000000 --- a/test/libyul/yulOptimizerTests/mainFunction/empty_block.yul +++ /dev/null @@ -1,28 +0,0 @@ -{ - let a:u256 - { } - function f() -> x:bool { - let b:u256 := 4:u256 - {} - for {} f() {} {} - } -} -// ==== -// dialect: yul -// ---- -// step: mainFunction -// -// { -// function main() -// { -// let a -// { } -// } -// function f() -> x:bool -// { -// let b := 4 -// { } -// for { } f() { } -// { } -// } -// } diff --git a/test/libyul/yulOptimizerTests/mainFunction/multi_fun_mixed.yul b/test/libyul/yulOptimizerTests/mainFunction/multi_fun_mixed.yul deleted file mode 100644 index 1d14937e7..000000000 --- a/test/libyul/yulOptimizerTests/mainFunction/multi_fun_mixed.yul +++ /dev/null @@ -1,24 +0,0 @@ -{ - let a:u256 - function f() { let b:u256 } - let c:u256 - function g() { let d:u256 } - let e:u256 -} -// ==== -// dialect: yul -// ---- -// step: mainFunction -// -// { -// function main() -// { -// let a -// let c -// let e -// } -// function f() -// { let b } -// function g() -// { let d } -// } diff --git a/test/libyul/yulOptimizerTests/mainFunction/nested_fun.yul b/test/libyul/yulOptimizerTests/mainFunction/nested_fun.yul deleted file mode 100644 index a888970e7..000000000 --- a/test/libyul/yulOptimizerTests/mainFunction/nested_fun.yul +++ /dev/null @@ -1,24 +0,0 @@ -{ - let a:u256 - function f() { - let b:u256 - function g() { let c:u256} - let d:u256 - } -} -// ==== -// dialect: yul -// ---- -// step: mainFunction -// -// { -// function main() -// { let a } -// function f() -// { -// let b -// function g() -// { let c } -// let d -// } -// } diff --git a/test/libyul/yulOptimizerTests/mainFunction/single_fun.yul b/test/libyul/yulOptimizerTests/mainFunction/single_fun.yul deleted file mode 100644 index 6b20d712c..000000000 --- a/test/libyul/yulOptimizerTests/mainFunction/single_fun.yul +++ /dev/null @@ -1,15 +0,0 @@ -{ - let a:u256 - function f() {} -} -// ==== -// dialect: yul -// ---- -// step: mainFunction -// -// { -// function main() -// { let a } -// function f() -// { } -// } diff --git a/test/libyul/yulOptimizerTests/mainFunction/smoke.yul b/test/libyul/yulOptimizerTests/mainFunction/smoke.yul deleted file mode 100644 index 5bad02dfb..000000000 --- a/test/libyul/yulOptimizerTests/mainFunction/smoke.yul +++ /dev/null @@ -1,10 +0,0 @@ -{} -// ==== -// dialect: yul -// ---- -// step: mainFunction -// -// { -// function main() -// { } -// }