mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove obsolete main function yul optimiser step.
This commit is contained in:
parent
310794089a
commit
aaba5c408a
@ -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
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// 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 <libyul/optimiser/MainFunction.h>
|
||||
|
||||
#include <libyul/optimiser/NameCollector.h>
|
||||
#include <libyul/Exceptions.h>
|
||||
|
||||
#include <libyul/AST.h>
|
||||
|
||||
#include <libsolutil/CommonData.h>
|
||||
|
||||
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>(_block.statements[0]), OptimizerException, "");
|
||||
for (size_t i = 1; i < _block.statements.size(); ++i)
|
||||
assertThrow(holds_alternative<FunctionDefinition>(_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>(_block.statements[0]);
|
||||
FunctionDefinition main{
|
||||
block.debugData,
|
||||
"main"_yulstring,
|
||||
{},
|
||||
{},
|
||||
std::move(block)
|
||||
};
|
||||
_block.statements[0] = std::move(main);
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// 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 <libyul/ASTForward.h>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
@ -40,7 +40,6 @@
|
||||
#include <libyul/optimiser/ForLoopInitRewriter.h>
|
||||
#include <libyul/optimiser/LoadResolver.h>
|
||||
#include <libyul/optimiser/LoopInvariantCodeMotion.h>
|
||||
#include <libyul/optimiser/MainFunction.h>
|
||||
#include <libyul/optimiser/StackLimitEvader.h>
|
||||
#include <libyul/optimiser/NameDisplacer.h>
|
||||
#include <libyul/optimiser/Rematerialiser.h>
|
||||
@ -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);
|
||||
|
@ -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() { }
|
||||
// { }
|
||||
// }
|
||||
// }
|
@ -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 }
|
||||
// }
|
@ -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
|
||||
// }
|
||||
// }
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
let a:u256
|
||||
function f() {}
|
||||
}
|
||||
// ====
|
||||
// dialect: yul
|
||||
// ----
|
||||
// step: mainFunction
|
||||
//
|
||||
// {
|
||||
// function main()
|
||||
// { let a }
|
||||
// function f()
|
||||
// { }
|
||||
// }
|
@ -1,10 +0,0 @@
|
||||
{}
|
||||
// ====
|
||||
// dialect: yul
|
||||
// ----
|
||||
// step: mainFunction
|
||||
//
|
||||
// {
|
||||
// function main()
|
||||
// { }
|
||||
// }
|
Loading…
Reference in New Issue
Block a user