Merge remote-tracking branch 'origin/develop' into merge_develop_060

This commit is contained in:
Leonardo Alt
2019-11-20 12:27:40 +01:00
104 changed files with 621 additions and 653 deletions
+12 -12
View File
@@ -51,7 +51,7 @@ FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser):
SSAValueTracker tracker;
tracker(m_ast);
for (auto const& ssaValue: tracker.values())
if (ssaValue.second && ssaValue.second->type() == typeid(Literal))
if (ssaValue.second && holds_alternative<Literal>(*ssaValue.second))
m_constants.emplace(ssaValue.first);
// Store size of global statements.
@@ -59,9 +59,9 @@ FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser):
map<YulString, size_t> references = ReferencesCounter::countReferences(m_ast);
for (auto& statement: m_ast.statements)
{
if (statement.type() != typeid(FunctionDefinition))
if (!holds_alternative<FunctionDefinition>(statement))
continue;
FunctionDefinition& fun = boost::get<FunctionDefinition>(statement);
FunctionDefinition& fun = std::get<FunctionDefinition>(statement);
m_functions[fun.name] = &fun;
if (LeaveFinder::containsLeave(fun))
m_noInlineFunctions.insert(fun.name);
@@ -75,8 +75,8 @@ FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser):
void FullInliner::run()
{
for (auto& statement: m_ast.statements)
if (statement.type() == typeid(Block))
handleBlock({}, boost::get<Block>(statement));
if (holds_alternative<Block>(statement))
handleBlock({}, std::get<Block>(statement));
// TODO it might be good to determine a visiting order:
// first handle functions that are called from many places.
@@ -115,9 +115,9 @@ bool FullInliner::shallInline(FunctionCall const& _funCall, YulString _callSite)
// Constant arguments might provide a means for further optimization, so they cause a bonus.
bool constantArg = false;
for (auto const& argument: _funCall.arguments)
if (argument.type() == typeid(Literal) || (
argument.type() == typeid(Identifier) &&
m_constants.count(boost::get<Identifier>(argument).name)
if (holds_alternative<Literal>(argument) || (
holds_alternative<Identifier>(argument) &&
m_constants.count(std::get<Identifier>(argument).name)
))
{
constantArg = true;
@@ -160,7 +160,7 @@ void InlineModifier::operator()(Block& _block)
std::optional<vector<Statement>> InlineModifier::tryInlineStatement(Statement& _statement)
{
// Only inline for expression statements, assignments and variable declarations.
Expression* e = boost::apply_visitor(GenericFallbackReturnsVisitor<Expression*, ExpressionStatement, Assignment, VariableDeclaration>(
Expression* e = std::visit(GenericFallbackReturnsVisitor<Expression*, ExpressionStatement, Assignment, VariableDeclaration>(
[](ExpressionStatement& _s) { return &_s.expression; },
[](Assignment& _s) { return _s.value.get(); },
[](VariableDeclaration& _s) { return _s.value.get(); }
@@ -168,7 +168,7 @@ std::optional<vector<Statement>> InlineModifier::tryInlineStatement(Statement& _
if (e)
{
// Only inline direct function calls.
FunctionCall* funCall = boost::apply_visitor(GenericFallbackReturnsVisitor<FunctionCall*, FunctionCall&>(
FunctionCall* funCall = std::visit(GenericFallbackReturnsVisitor<FunctionCall*, FunctionCall&>(
[](FunctionCall& _e) { return &_e; }
), *e);
if (funCall && m_driver.shallInline(*funCall, m_currentFunction))
@@ -206,9 +206,9 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC
newVariable(var, nullptr);
Statement newBody = BodyCopier(m_nameDispenser, variableReplacements)(function->body);
newStatements += std::move(boost::get<Block>(newBody).statements);
newStatements += std::move(std::get<Block>(newBody).statements);
boost::apply_visitor(GenericFallbackVisitor<Assignment, VariableDeclaration>{
std::visit(GenericFallbackVisitor<Assignment, VariableDeclaration>{
[&](Assignment& _assignment)
{
for (size_t i = 0; i < _assignment.variableNames.size(); ++i)