Add dependencies on Disambiguator, ForLoopConditionIntoBody and ExpressionSplitter.

This commit is contained in:
Daniel Kirchner 2021-06-14 20:39:04 +02:00
parent 187598f5a8
commit f1a04d3098
136 changed files with 440 additions and 450 deletions

View File

@ -24,7 +24,8 @@
#include <libyul/AST.h>
#include <libyul/AsmAnalysisInfo.h>
#include <libyul/Dialect.h>
#include <libyul/Scope.h>
#include <libsolutil/Common.h>
#include <functional>
#include <list>
@ -51,10 +52,10 @@ struct FunctionReturnLabelSlot
/// A slot containing the current value of a particular variable.
struct VariableSlot
{
std::reference_wrapper<Scope::Variable const> variable;
YulString variable;
std::shared_ptr<DebugData const> debugData{};
bool operator==(VariableSlot const& _rhs) const { return &variable.get() == &_rhs.variable.get(); }
bool operator<(VariableSlot const& _rhs) const { return &variable.get() < &_rhs.variable.get(); }
bool operator==(VariableSlot const& _rhs) const { return variable == _rhs.variable; }
bool operator<(VariableSlot const& _rhs) const { return variable < _rhs.variable; }
static constexpr bool canBeFreelyGenerated = false;
};
/// A slot containing a literal value.
@ -66,18 +67,6 @@ struct LiteralSlot
bool operator<(LiteralSlot const& _rhs) const { return value < _rhs.value; }
static constexpr bool canBeFreelyGenerated = true;
};
/// A slot containing the idx-th return value of a previous call.
struct TemporarySlot
{
/// The call that returned this slot.
std::reference_wrapper<yul::FunctionCall const> call;
/// Specifies to which of the values returned by the call this slot refers.
/// index == 0 refers to the slot deepest in the stack after the call.
size_t index = 0;
bool operator==(TemporarySlot const& _rhs) const { return &call.get() == &_rhs.call.get() && index == _rhs.index; }
bool operator<(TemporarySlot const& _rhs) const { return std::make_pair(&call.get(), index) < std::make_pair(&_rhs.call.get(), _rhs.index); }
static constexpr bool canBeFreelyGenerated = false;
};
/// A slot containing an arbitrary value that is always eventually popped and never used.
/// Used to maintain stack balance on control flow joins.
struct JunkSlot
@ -86,7 +75,7 @@ struct JunkSlot
bool operator<(JunkSlot const&) const { return false; }
static constexpr bool canBeFreelyGenerated = true;
};
using StackSlot = std::variant<FunctionCallReturnLabelSlot, FunctionReturnLabelSlot, VariableSlot, LiteralSlot, TemporarySlot, JunkSlot>;
using StackSlot = std::variant<FunctionCallReturnLabelSlot, FunctionReturnLabelSlot, VariableSlot, LiteralSlot, JunkSlot>;
/// The stack top is usually the last element of the vector.
using Stack = std::vector<StackSlot>;
@ -116,15 +105,12 @@ struct CFG
struct FunctionCall
{
std::shared_ptr<DebugData const> debugData;
std::reference_wrapper<Scope::Function const> function;
std::reference_wrapper<yul::FunctionCall const> functionCall;
std::reference_wrapper<FunctionDefinition const> referencedFunction;
};
struct Assignment
{
std::shared_ptr<DebugData const> debugData;
/// The variables being assigned to also occur as ``output`` in the ``Operation`` containing
/// the assignment, but are also stored here for convenience.
std::vector<VariableSlot> variables;
};
struct Operation
@ -164,25 +150,21 @@ struct CFG
struct FunctionInfo
{
std::shared_ptr<DebugData const> debugData;
Scope::Function const& function;
yul::FunctionDefinition const* function = nullptr;
BasicBlock* entry = nullptr;
std::vector<VariableSlot> parameters;
std::vector<VariableSlot> returnVariables;
};
/// The main entry point, i.e. the start of the outermost Yul block.
BasicBlock* entry = nullptr;
/// Subgraphs for functions.
std::map<Scope::Function const*, FunctionInfo> functionInfo;
std::map<YulString, FunctionInfo> functionInfo;
/// List of functions in order of declaration.
std::list<Scope::Function const*> functions;
std::list<YulString> functions;
/// Container for blocks for explicit ownership.
std::list<BasicBlock> blocks;
/// Container for creates variables for explicit ownership.
std::list<Scope::Variable> ghostVariables;
/// Container for creates calls for explicit ownership.
std::list<yul::FunctionCall> ghostCalls;
/// Container for created variables for explicit ownership.
std::list<yul::VariableDeclaration> ghostVariable;
BasicBlock& makeBlock()
{

View File

@ -25,12 +25,16 @@
#include <libyul/Utilities.h>
#include <libyul/AsmPrinter.h>
#include <libyul/optimiser/FunctionDefinitionCollector.h>
#include <libsolutil/cxx20.h>
#include <libsolutil/Visitor.h>
#include <libsolutil/Algorithms.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/Visitor.h>
#include <range/v3/action/push_back.hpp>
#include <range/v3/action/erase.hpp>
#include <range/v3/algorithm/remove.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/concat.hpp>
#include <range/v3/view/drop_last.hpp>
@ -47,6 +51,26 @@ using namespace solidity;
using namespace solidity::yul;
using namespace std;
namespace
{
template<typename Block, typename Callable>
void forEachExit(Block&& _block, Callable _callable)
{
std::visit(util::GenericVisitor{
[&](CFG::BasicBlock::Jump& _jump) {
_callable(_jump.target);
},
[&](CFG::BasicBlock::ConditionalJump& _jump) {
_callable(_jump.zero);
_callable(_jump.nonZero);
},
[](CFG::BasicBlock::FunctionReturn&) {},
[](CFG::BasicBlock::Terminated&) {},
[](CFG::BasicBlock::MainExit&) {}
}, _block.exit);
}
}
std::unique_ptr<CFG> ControlFlowGraphBuilder::build(
AsmAnalysisInfo& _analysisInfo,
Dialect const& _dialect,
@ -56,39 +80,75 @@ std::unique_ptr<CFG> ControlFlowGraphBuilder::build(
auto result = std::make_unique<CFG>();
result->entry = &result->makeBlock();
ControlFlowGraphBuilder builder(*result, _analysisInfo, _dialect);
auto functionDefinitions = FunctionDefinitionCollector::run(_block);
ControlFlowGraphBuilder builder(*result, _analysisInfo, _dialect, functionDefinitions);
builder.m_currentBlock = result->entry;
builder(_block);
// Determine which blocks are reachable from the entry.
util::BreadthFirstSearch<CFG::BasicBlock*> reachabilityCheck{{result->entry}};
list<CFG::BasicBlock*> allEntries{result->entry};
ranges::actions::push_back(
reachabilityCheck.verticesToTraverse,
allEntries,
result->functionInfo | ranges::views::values | ranges::views::transform(
[](auto&& _function) { return _function.entry; }
)
);
reachabilityCheck.run([&](CFG::BasicBlock* _node, auto&& _addChild) {
visit(util::GenericVisitor{
[&](CFG::BasicBlock::Jump& _jump) {
_addChild(_jump.target);
},
[&](CFG::BasicBlock::ConditionalJump& _jump) {
_addChild(_jump.zero);
_addChild(_jump.nonZero);
},
[](CFG::BasicBlock::FunctionReturn&) {},
[](CFG::BasicBlock::Terminated&) {},
[](CFG::BasicBlock::MainExit&) {}
}, _node->exit);
});
// Remove all entries from unreachable nodes from the graph.
for (auto* node: reachabilityCheck.visited)
cxx20::erase_if(node->entries, [&](CFG::BasicBlock* entry) -> bool {
return !reachabilityCheck.visited.count(entry);
{
// Determine which blocks are reachable from the entry.
util::BreadthFirstSearch<CFG::BasicBlock*> reachabilityCheck{allEntries};
reachabilityCheck.run([&](CFG::BasicBlock* _node, auto&& _addChild) {
visit(util::GenericVisitor{
[&](CFG::BasicBlock::Jump& _jump) {
_addChild(_jump.target);
},
[&](CFG::BasicBlock::ConditionalJump& _jump) {
_addChild(_jump.zero);
_addChild(_jump.nonZero);
},
[](CFG::BasicBlock::FunctionReturn&) {},
[](CFG::BasicBlock::Terminated&) {},
[](CFG::BasicBlock::MainExit&) {}
}, _node->exit);
});
// Remove all entries from unreachable nodes from the graph.
for (auto* node: reachabilityCheck.visited)
cxx20::erase_if(node->entries, [&](CFG::BasicBlock* entry) -> bool {
return !reachabilityCheck.visited.count(entry);
});
}
{
// Merge any block with only one entry forward-jumping to it with its entry.
util::BreadthFirstSearch<CFG::BasicBlock*> reachabilityCheck{allEntries};
reachabilityCheck.run([&](CFG::BasicBlock* _node, auto&& _addChild) {
if (CFG::BasicBlock* _entry = (_node->entries.size() == 1) ? _node->entries.front() : nullptr)
if (CFG::BasicBlock::Jump* jump = get_if<CFG::BasicBlock::Jump>(&_entry->exit))
if (!jump->backwards)
{
_entry->operations += std::move(_node->operations);
_node->operations.clear();
_entry->exit = _node->exit;
forEachExit(*_node, [&](CFG::BasicBlock* _exit) {
ranges::remove(_exit->entries, _node);
_exit->entries.emplace_back(_entry);
});
}
visit(util::GenericVisitor{
[&](CFG::BasicBlock::Jump& _jump) {
_addChild(_jump.target);
},
[&](CFG::BasicBlock::ConditionalJump& _jump) {
_addChild(_jump.zero);
_addChild(_jump.nonZero);
},
[](CFG::BasicBlock::FunctionReturn&) {},
[](CFG::BasicBlock::Terminated&) {},
[](CFG::BasicBlock::MainExit&) {}
}, _node->exit);
});
}
// TODO: It might be worthwhile to run some further simplifications on the graph itself here.
// E.g. if there is a jump to a node that has the jumping node as its only entry, the nodes can be fused, etc.
@ -98,11 +158,13 @@ std::unique_ptr<CFG> ControlFlowGraphBuilder::build(
ControlFlowGraphBuilder::ControlFlowGraphBuilder(
CFG& _graph,
AsmAnalysisInfo& _analysisInfo,
Dialect const& _dialect
Dialect const& _dialect,
map<YulString, FunctionDefinition const*> const& _functionDefinitions
):
m_graph(_graph),
m_info(_analysisInfo),
m_dialect(_dialect)
m_dialect(_dialect),
m_functionDefinitions(_functionDefinitions)
{
}
@ -113,7 +175,7 @@ StackSlot ControlFlowGraphBuilder::operator()(Literal const& _literal)
StackSlot ControlFlowGraphBuilder::operator()(Identifier const& _identifier)
{
return VariableSlot{lookupVariable(_identifier.name), _identifier.debugData};
return VariableSlot{_identifier.name, _identifier.debugData};
}
StackSlot ControlFlowGraphBuilder::operator()(Expression const& _expression)
@ -121,9 +183,8 @@ StackSlot ControlFlowGraphBuilder::operator()(Expression const& _expression)
return std::visit(*this, _expression);
}
CFG::Operation& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _call)
CFG::Operation& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _call, vector<VariableSlot> _outputs)
{
yulAssert(m_scope, "");
yulAssert(m_currentBlock, "");
if (BuiltinFunction const* builtin = m_dialect.builtin(_call.functionName.name))
@ -140,9 +201,7 @@ CFG::Operation& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _
ranges::views::transform(std::ref(*this)) |
ranges::to<Stack>,
// output
ranges::views::iota(0u, builtin->returns.size()) | ranges::views::transform([&](size_t _i) {
return TemporarySlot{_call, _i};
}) | ranges::to<Stack>,
_outputs | ranges::to<Stack>,
// operation
CFG::BuiltinCall{_call.debugData, *builtin, _call}
});
@ -151,12 +210,8 @@ CFG::Operation& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _
}
else
{
Scope::Function* function = nullptr;
yulAssert(m_scope->lookup(_call.functionName.name, util::GenericVisitor{
[](Scope::Variable&) { yulAssert(false, "Expected function name."); },
[&](Scope::Function& _function) { function = &_function; }
}), "Function name not found.");
yulAssert(function, "");
yul::FunctionDefinition const* functionDefinition = m_functionDefinitions.at(_call.functionName.name);
yulAssert(functionDefinition, "");
return m_currentBlock->operations.emplace_back(CFG::Operation{
// input
ranges::concat_view(
@ -164,41 +219,34 @@ CFG::Operation& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _
_call.arguments | ranges::views::reverse | ranges::views::transform(std::ref(*this))
) | ranges::to<Stack>,
// output
ranges::views::iota(0u, function->returns.size()) | ranges::views::transform([&](size_t _i) {
return TemporarySlot{_call, _i};
}) | ranges::to<Stack>,
_outputs | ranges::to<Stack>,
// operation
CFG::FunctionCall{_call.debugData, *function, _call}
CFG::FunctionCall{_call.debugData, _call, *functionDefinition}
});
}
}
StackSlot ControlFlowGraphBuilder::operator()(FunctionCall const& _call)
StackSlot ControlFlowGraphBuilder::operator()(FunctionCall const&)
{
CFG::Operation& operation = visitFunctionCall(_call);
yulAssert(operation.output.size() == 1, "");
return operation.output.front();
yulAssert(false, "Expected split expressions.");
return JunkSlot{};
}
void ControlFlowGraphBuilder::operator()(VariableDeclaration const& _varDecl)
{
yulAssert(m_currentBlock, "");
auto declaredVariables = _varDecl.variables | ranges::views::transform([&](TypedName const& _var) {
return VariableSlot{lookupVariable(_var.name), _var.debugData};
return VariableSlot{_var.name, _var.debugData};
}) | ranges::to<vector>;
Stack input;
if (_varDecl.value)
input = std::visit(util::GenericVisitor{
[&](FunctionCall const& _call) -> Stack {
CFG::Operation& operation = visitFunctionCall(_call);
yulAssert(declaredVariables.size() == operation.output.size(), "");
return operation.output;
},
[&](auto const& _identifierOrLiteral) -> Stack{
yulAssert(declaredVariables.size() == 1, "");
return {(*this)(_identifierOrLiteral)};
}
}, *_varDecl.value);
if (FunctionCall const* call = get_if<FunctionCall>(_varDecl.value.get()))
{
visitFunctionCall(*call, std::move(declaredVariables));
return;
}
else
input = {std::visit(std::ref(*this), *_varDecl.value)};
else
input = ranges::views::iota(0u, _varDecl.variables.size()) | ranges::views::transform([&](size_t) {
return LiteralSlot{0, _varDecl.debugData};
@ -206,33 +254,30 @@ void ControlFlowGraphBuilder::operator()(VariableDeclaration const& _varDecl)
m_currentBlock->operations.emplace_back(CFG::Operation{
std::move(input),
declaredVariables | ranges::to<Stack>,
CFG::Assignment{_varDecl.debugData, declaredVariables}
CFG::Assignment{_varDecl.debugData}
});
}
void ControlFlowGraphBuilder::operator()(Assignment const& _assignment)
{
vector<VariableSlot> assignedVariables = _assignment.variableNames | ranges::views::transform([&](Identifier const& _var) {
return VariableSlot{lookupVariable(_var.name), _var.debugData};
return VariableSlot{_var.name, _var.debugData};
}) | ranges::to<vector<VariableSlot>>;
yulAssert(m_currentBlock, "");
if (FunctionCall const* call = get_if<FunctionCall>(_assignment.value.get()))
{
visitFunctionCall(*call, std::move(assignedVariables));
return;
}
else
m_currentBlock->operations.emplace_back(CFG::Operation{
// input
std::visit(util::GenericVisitor{
[&](FunctionCall const& _call) -> Stack {
CFG::Operation& operation = visitFunctionCall(_call);
yulAssert(assignedVariables.size() == operation.output.size(), "");
return operation.output;
},
[&](auto const& _identifierOrLiteral) -> Stack {
yulAssert(assignedVariables.size() == 1, "");
return {(*this)(_identifierOrLiteral)};
}
}, *_assignment.value),
{std::visit(std::ref(*this), *_assignment.value)},
// output
assignedVariables | ranges::to<Stack>,
// operation
CFG::Assignment{_assignment.debugData, assignedVariables}
CFG::Assignment{_assignment.debugData}
});
}
void ControlFlowGraphBuilder::operator()(ExpressionStatement const& _exprStmt)
@ -240,7 +285,7 @@ void ControlFlowGraphBuilder::operator()(ExpressionStatement const& _exprStmt)
yulAssert(m_currentBlock, "");
std::visit(util::GenericVisitor{
[&](FunctionCall const& _call) {
CFG::Operation& operation = visitFunctionCall(_call);
CFG::Operation& operation = visitFunctionCall(_call, {});
yulAssert(operation.output.empty(), "");
},
[&](auto const&) { yulAssert(false, ""); }
@ -259,7 +304,6 @@ void ControlFlowGraphBuilder::operator()(ExpressionStatement const& _exprStmt)
void ControlFlowGraphBuilder::operator()(Block const& _block)
{
ScopedSaveAndRestore saveScope(m_scope, m_info.scopes.at(&_block).get());
for (auto const& statement: _block.statements)
std::visit(*this, statement);
}
@ -304,18 +348,7 @@ void ControlFlowGraphBuilder::operator()(If const& _if)
void ControlFlowGraphBuilder::operator()(Switch const& _switch)
{
yulAssert(m_currentBlock, "");
auto ghostVariableId = m_graph.ghostVariables.size();
YulString ghostVariableName("GHOST[" + to_string(ghostVariableId) + "]");
auto& ghostVar = m_graph.ghostVariables.emplace_back(Scope::Variable{""_yulstring, ghostVariableName});
// Artificially generate:
// let <ghostVariable> := <switchExpression>
VariableSlot ghostVarSlot{ghostVar, debugDataOf(*_switch.expression)};
m_currentBlock->operations.emplace_back(CFG::Operation{
Stack{std::visit(*this, *_switch.expression)},
Stack{ghostVarSlot},
CFG::Assignment{_switch.debugData, {ghostVarSlot}}
});
StackSlot switchExpression = std::visit(std::ref(*this), *_switch.expression);
BuiltinFunction const* equalityBuiltin = m_dialect.equalityFunction({});
yulAssert(equalityBuiltin, "");
@ -323,15 +356,23 @@ void ControlFlowGraphBuilder::operator()(Switch const& _switch)
// Artificially generate:
// eq(<literal>, <ghostVariable>)
auto makeValueCompare = [&](Literal const& _value) {
yul::FunctionCall const& ghostCall = m_graph.ghostCalls.emplace_back(yul::FunctionCall{
size_t ghostVariableId = m_graph.ghostVariable.size();
// TODO: properly use NameDispenser to generate names for these.
YulString ghostVarName = YulString{"GHOST[" + to_string(ghostVariableId) + "]"};
VariableDeclaration& ghostDecl = m_graph.ghostVariable.emplace_back(VariableDeclaration{
_value.debugData,
yul::Identifier{{}, "eq"_yulstring},
{_value, Identifier{{}, ghostVariableName}}
{TypedName{_value.debugData, ghostVarName, {}}},
std::make_unique<Expression>(yul::FunctionCall{
_value.debugData,
yul::Identifier{{}, "eq"_yulstring},
{_value, *_switch.expression}
})
});
CFG::Operation& operation = m_currentBlock->operations.emplace_back(CFG::Operation{
Stack{ghostVarSlot, LiteralSlot{valueOfLiteral(_value), _value.debugData}},
Stack{TemporarySlot{ghostCall, 0}},
CFG::BuiltinCall{_switch.debugData, *equalityBuiltin, ghostCall, 2},
Stack{switchExpression, LiteralSlot{valueOfLiteral(_value), _value.debugData}},
Stack{VariableSlot{ghostVarName, _value.debugData}},
CFG::BuiltinCall{_switch.debugData, *equalityBuiltin, get<yul::FunctionCall>(*ghostDecl.value.get()), 2},
});
return operation.output.front();
};
@ -360,7 +401,6 @@ void ControlFlowGraphBuilder::operator()(Switch const& _switch)
void ControlFlowGraphBuilder::operator()(ForLoop const& _loop)
{
ScopedSaveAndRestore scopeRestore(m_scope, m_info.scopes.at(&_loop.pre).get());
(*this)(_loop.pre);
std::optional<bool> constantCondition;
@ -429,56 +469,18 @@ void ControlFlowGraphBuilder::operator()(Leave const&)
void ControlFlowGraphBuilder::operator()(FunctionDefinition const& _function)
{
yulAssert(m_scope, "");
yulAssert(m_scope->identifiers.count(_function.name), "");
Scope::Function& function = std::get<Scope::Function>(m_scope->identifiers.at(_function.name));
m_graph.functions.emplace_back(&function);
yulAssert(m_info.scopes.at(&_function.body), "");
Scope* virtualFunctionScope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get();
yulAssert(virtualFunctionScope, "");
auto&& [it, inserted] = m_graph.functionInfo.emplace(std::make_pair(&function, CFG::FunctionInfo{
m_graph.functions.emplace_back(_function.name);
auto&& [it, inserted] = m_graph.functionInfo.emplace(std::make_pair(_function.name, CFG::FunctionInfo{
_function.debugData,
function,
&m_graph.makeBlock(),
_function.parameters | ranges::views::transform([&](auto const& _param) {
return VariableSlot{
std::get<Scope::Variable>(virtualFunctionScope->identifiers.at(_param.name)),
_param.debugData
};
}) | ranges::to<vector>,
_function.returnVariables | ranges::views::transform([&](auto const& _retVar) {
return VariableSlot{
std::get<Scope::Variable>(virtualFunctionScope->identifiers.at(_retVar.name)),
_retVar.debugData
};
}) | ranges::to<vector>
&_function,
&m_graph.makeBlock()
}));
yulAssert(inserted, "");
CFG::FunctionInfo& info = it->second;
ControlFlowGraphBuilder builder{m_graph, m_info, m_dialect};
ControlFlowGraphBuilder builder{m_graph, m_info, m_dialect, m_functionDefinitions};
builder.m_currentFunctionExit = CFG::BasicBlock::FunctionReturn{&info};
builder.m_currentBlock = info.entry;
builder(_function.body);
builder.m_currentBlock->exit = CFG::BasicBlock::FunctionReturn{&info};
}
Scope::Variable const& ControlFlowGraphBuilder::lookupVariable(YulString _name) const
{
yulAssert(m_scope, "");
Scope::Variable *var = nullptr;
if (m_scope->lookup(_name, util::GenericVisitor{
[&](Scope::Variable& _var) { var = &_var; },
[](Scope::Function&)
{
yulAssert(false, "Function not removed during desugaring.");
}
}))
{
yulAssert(var, "");
return *var;
};
yulAssert(false, "External identifier access unimplemented.");
}

View File

@ -55,19 +55,19 @@ private:
ControlFlowGraphBuilder(
CFG& _graph,
AsmAnalysisInfo& _analysisInfo,
Dialect const& _dialect
Dialect const& _dialect,
std::map<YulString, FunctionDefinition const*> const& _functionDefinitions
);
CFG::Operation& visitFunctionCall(FunctionCall const&);
CFG::Operation& visitFunctionCall(FunctionCall const& _call, std::vector<VariableSlot> _outputs);
Scope::Variable const& lookupVariable(YulString _name) const;
std::pair<CFG::BasicBlock*, CFG::BasicBlock*> makeConditionalJump(StackSlot _condition);
void makeConditionalJump(StackSlot _condition, CFG::BasicBlock& _nonZero, CFG::BasicBlock& _zero);
void jump(CFG::BasicBlock& _target, bool _backwards = false);
CFG& m_graph;
AsmAnalysisInfo& m_info;
Dialect const& m_dialect;
std::map<YulString, FunctionDefinition const*> const& m_functionDefinitions;
CFG::BasicBlock* m_currentBlock = nullptr;
Scope* m_scope = nullptr;
struct ForLoopInfo
{
std::reference_wrapper<CFG::BasicBlock> afterLoop;

View File

@ -25,6 +25,8 @@
#include <libyul/backends/evm/EVMDialect.h>
#include <libyul/backends/evm/OptimizedEVMCodeTransform.h>
#include <libyul/optimiser/Disambiguator.h>
#include <libyul/Object.h>
#include <libyul/Exceptions.h>
@ -42,7 +44,6 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize)
BuiltinContext context;
context.currentObject = &_object;
for (auto const& subNode: _object.subObjects)
if (auto* subObject = dynamic_cast<Object*>(subNode.get()))
{

View File

@ -21,6 +21,11 @@
#include <libyul/backends/evm/StackHelpers.h>
#include <libyul/backends/evm/StackLayoutGenerator.h>
#include <libyul/optimiser/Disambiguator.h>
#include <libyul/optimiser/ExpressionSplitter.h>
#include <libyul/optimiser/ForLoopConditionIntoBody.h>
#include <libyul/optimiser/OptimiserStep.h>
#include <libyul/Utilities.h>
#include <libsolutil/Permutations.h>
@ -60,20 +65,20 @@ void OptimizedEVMCodeTransform::assertLayoutCompatibility(Stack const& _currentS
yulAssert(holds_alternative<JunkSlot>(desiredSlot) || currentSlot == desiredSlot, "");
}
AbstractAssembly::LabelID OptimizedEVMCodeTransform::getFunctionLabel(Scope::Function const& _function)
AbstractAssembly::LabelID OptimizedEVMCodeTransform::getFunctionLabel(YulString _functionName)
{
CFG::FunctionInfo const& functionInfo = m_dfg.functionInfo.at(&_function);
if (!m_functionLabels.count(&functionInfo))
CFG::FunctionInfo const& functionInfo = m_dfg.functionInfo.at(_functionName);
if (!m_functionLabels.count(_functionName))
{
m_functionLabels[&functionInfo] = m_useNamedLabelsForFunctions ?
m_functionLabels[_functionName] = m_useNamedLabelsForFunctions ?
m_assembly.namedLabel(
functionInfo.function.name.str(),
functionInfo.function.arguments.size(),
functionInfo.function.returns.size(),
functionInfo.function->name.str(),
functionInfo.function->parameters.size(),
functionInfo.function->returnVariables.size(),
{}
) : m_assembly.newLabelId();
}
return m_functionLabels[&functionInfo];
return m_functionLabels[_functionName];
}
void OptimizedEVMCodeTransform::validateSlot(StackSlot const& _slot, Expression const& _expression)
@ -85,11 +90,10 @@ void OptimizedEVMCodeTransform::validateSlot(StackSlot const& _slot, Expression
},
[&](yul::Identifier const& _identifier) {
auto* variableSlot = get_if<VariableSlot>(&_slot);
yulAssert(variableSlot && variableSlot->variable.get().name == _identifier.name, "");
yulAssert(variableSlot && variableSlot->variable == _identifier.name, "");
},
[&](yul::FunctionCall const& _call) {
auto* temporarySlot = get_if<TemporarySlot>(&_slot);
yulAssert(temporarySlot && &temporarySlot->call.get() == &_call, "");
[&](yul::FunctionCall const&) {
yulAssert(false, "Expected split expressions.");
}
}, _expression);
}
@ -103,14 +107,11 @@ void OptimizedEVMCodeTransform::operator()(CFG::FunctionInfo const& _functionInf
m_stack.clear();
m_stack.emplace_back(FunctionReturnLabelSlot{});
for (auto const& param: _functionInfo.parameters | ranges::views::reverse)
m_stack.emplace_back(param);
for (auto const& param: _functionInfo.function->parameters | ranges::views::reverse)
m_stack.emplace_back(VariableSlot{param.name, param.debugData});
m_assembly.setStackHeight(static_cast<int>(m_stack.size()));
m_assembly.setSourceLocation(locationOf(_functionInfo));
if (!m_functionLabels.count(&_functionInfo))
m_functionLabels[&_functionInfo] = m_assembly.newLabelId();
m_assembly.appendLabel(getFunctionLabel(_functionInfo.function));
m_assembly.appendLabel(getFunctionLabel(_functionInfo.function->name));
createStackLayout(entryLayout);
(*this)(*_functionInfo.entry);
@ -122,7 +123,7 @@ void OptimizedEVMCodeTransform::operator()(CFG::FunctionInfo const& _functionInf
void OptimizedEVMCodeTransform::operator()(CFG::FunctionCall const& _call)
{
yulAssert(m_stack.size() >= _call.function.get().arguments.size() + 1, "");
yulAssert(m_stack.size() >= _call.referencedFunction.get().parameters.size() + 1, "");
auto returnLabel = m_returnLabels.at(&_call.functionCall.get());
// Assert that we got a correct arguments on stack for the call.
@ -137,21 +138,11 @@ void OptimizedEVMCodeTransform::operator()(CFG::FunctionCall const& _call)
m_assembly.setSourceLocation(locationOf(_call));
m_assembly.appendJumpTo(
getFunctionLabel(_call.function),
static_cast<int>(_call.function.get().returns.size() - _call.function.get().arguments.size()) - 1,
getFunctionLabel(_call.functionCall.get().functionName.name),
static_cast<int>(_call.referencedFunction.get().returnVariables.size() - _call.referencedFunction.get().parameters.size()) - 1,
AbstractAssembly::JumpType::IntoFunction
);
m_assembly.appendLabel(returnLabel);
// Remove arguments and return label from m_stack.
for (size_t i = 0; i < _call.function.get().arguments.size() + 1; ++i)
m_stack.pop_back();
// Push return values to m_stack.
ranges::actions::push_back(
m_stack,
ranges::views::iota(0u, _call.function.get().returns.size()) |
ranges::views::transform([&](size_t _i) -> StackSlot { return TemporarySlot{_call.functionCall, _i}; })
);
yulAssert(m_assembly.stackHeight() == static_cast<int>(m_stack.size()), "");
}
void OptimizedEVMCodeTransform::operator()(CFG::BuiltinCall const& _call)
@ -168,27 +159,10 @@ void OptimizedEVMCodeTransform::operator()(CFG::BuiltinCall const& _call)
m_assembly.setSourceLocation(locationOf(_call));
static_cast<BuiltinFunctionForEVM const&>(_call.builtin.get()).generateCode(_call.functionCall, m_assembly, m_builtinContext, [](auto&&){});
// Remove arguments from m_stack.
for (size_t i = 0; i < _call.arguments; ++i)
m_stack.pop_back();
// Push return values to m_stack.
ranges::actions::push_back(
m_stack,
ranges::views::iota(0u, _call.builtin.get().returns.size()) |
ranges::views::transform([&](size_t _i) -> StackSlot { return TemporarySlot{_call.functionCall, _i};})
);
yulAssert(m_assembly.stackHeight() == static_cast<int>(m_stack.size()), "");
}
void OptimizedEVMCodeTransform::operator()(CFG::Assignment const& _assignment)
void OptimizedEVMCodeTransform::operator()(CFG::Assignment const&)
{
for (auto& currentSlot: m_stack)
if (VariableSlot const* varSlot = get_if<VariableSlot>(&currentSlot))
if (util::findOffset(_assignment.variables, *varSlot))
currentSlot = JunkSlot{};
for (auto&& [currentSlot, varSlot]: ranges::zip_view(m_stack | ranges::views::take_last(_assignment.variables.size()), _assignment.variables))
currentSlot = varSlot;
}
void OptimizedEVMCodeTransform::operator()(CFG::BasicBlock const& _block)
@ -209,6 +183,14 @@ void OptimizedEVMCodeTransform::operator()(CFG::BasicBlock const& _block)
{
createStackLayout(m_stackLayout.operationEntryLayout.at(&operation));
std::visit(*this, operation.operation);
for (auto& currentSlot: m_stack)
if (util::findOffset(operation.output, currentSlot))
currentSlot = JunkSlot{};
for (size_t i = 0; i < operation.input.size(); ++i)
m_stack.pop_back();
m_stack += operation.output;
}
createStackLayout(exitLayout);
@ -271,8 +253,8 @@ void OptimizedEVMCodeTransform::operator()(CFG::BasicBlock const& _block)
yulAssert(m_currentFunctionInfo, "");
yulAssert(m_currentFunctionInfo == _functionReturn.info, "");
Stack exitStack = m_currentFunctionInfo->returnVariables | ranges::views::transform([](auto const& _varSlot){
return StackSlot{_varSlot};
Stack exitStack = m_currentFunctionInfo->function->returnVariables | ranges::views::transform([](auto const& _var){
return StackSlot{VariableSlot{_var.name, _var.debugData}};
}) | ranges::to<Stack>;
exitStack.emplace_back(FunctionReturnLabelSlot{});
@ -401,7 +383,10 @@ void OptimizedEVMCodeTransform::createStackLayout(Stack _targetStack)
[&](VariableSlot const& _variable)
{
if (m_currentFunctionInfo)
if (util::contains(m_currentFunctionInfo->returnVariables, _variable))
if (util::contains_if(
m_currentFunctionInfo->function->returnVariables,
[&](TypedName const& _var) { return _var.name == _variable.variable; }
))
{
// TODO: maybe track uninitialized return variables.
m_assembly.appendConstant(0);
@ -409,10 +394,6 @@ void OptimizedEVMCodeTransform::createStackLayout(Stack _targetStack)
}
yulAssert(false, "Variable not found on stack.");
},
[&](TemporarySlot const&)
{
yulAssert(false, "Function call result requested, but not found on stack.");
},
[&](JunkSlot const&)
{
// Note: this will always be popped, so we can push anything.
@ -439,6 +420,27 @@ void OptimizedEVMCodeTransform::createStackLayout(Stack _targetStack)
m_stack.emplace_back(slot);
}
namespace
{
Block preprocess(EVMDialect const& _dialect, AsmAnalysisInfo const& _analysisInfo, Block const& _block)
{
std::set<YulString> externallyUsedIdentifiers;
Disambiguator disambiguator{_dialect, _analysisInfo, externallyUsedIdentifiers};
Block resultBlock = disambiguator.translate(_block);
NameDispenser nameDispenser{_dialect, resultBlock, {}};
std::set<YulString> reservedIdentifiers;
OptimiserStepContext context{
_dialect,
nameDispenser,
reservedIdentifiers,
nullopt // TODO: pass a proper value in here?
};
ForLoopConditionIntoBody::run(context, resultBlock);
ExpressionSplitter::run(context, resultBlock);
return resultBlock;
}
}
void OptimizedEVMCodeTransform::run(
AbstractAssembly& _assembly,
AsmAnalysisInfo& _analysisInfo,
@ -449,10 +451,11 @@ void OptimizedEVMCodeTransform::run(
bool _useNamedLabelsForFunctions
)
{
std::unique_ptr<CFG> dfg = ControlFlowGraphBuilder::build(_analysisInfo, _dialect, _block);
Block block = preprocess(_dialect, _analysisInfo, _block);
std::unique_ptr<CFG> dfg = ControlFlowGraphBuilder::build(_analysisInfo, _dialect, block);
StackLayout stackLayout = StackLayoutGenerator::run(*dfg);
OptimizedEVMCodeTransform optimizedCodeTransform(_assembly, _builtinContext, _useNamedLabelsForFunctions, *dfg, stackLayout);
optimizedCodeTransform(*dfg->entry);
for (Scope::Function const* function: dfg->functions)
for (YulString function: dfg->functions)
optimizedCodeTransform(dfg->functionInfo.at(function));
}

View File

@ -60,7 +60,7 @@ private:
StackLayout const& _stackLayout
);
AbstractAssembly::LabelID getFunctionLabel(Scope::Function const& _function);
AbstractAssembly::LabelID getFunctionLabel(YulString _functionName);
/// Shuffles m_stack to the desired @a _targetStack while emitting the shuffling code to m_assembly.
void createStackLayout(Stack _targetStack);
@ -100,7 +100,7 @@ private:
Stack m_stack;
std::map<yul::FunctionCall const*, AbstractAssembly::LabelID> m_returnLabels;
std::map<CFG::BasicBlock const*, AbstractAssembly::LabelID> m_blockLabels;
std::map<CFG::FunctionInfo const*, AbstractAssembly::LabelID> m_functionLabels;
std::map<YulString, AbstractAssembly::LabelID> m_functionLabels;
/// Set of blocks already generated. If any of the contained blocks is ever jumped to, m_blockLabels should
/// contain a jump label for it.
std::set<CFG::BasicBlock const*> m_generated;

View File

@ -34,9 +34,8 @@ inline std::string stackSlotToString(StackSlot const& _slot)
return std::visit(util::GenericVisitor{
[](FunctionCallReturnLabelSlot const& _ret) -> std::string { return "RET[" + _ret.call.get().functionName.name.str() + "]"; },
[](FunctionReturnLabelSlot const&) -> std::string { return "RET"; },
[](VariableSlot const& _var) { return _var.variable.get().name.str(); },
[](VariableSlot const& _var) { return _var.variable.str(); },
[](LiteralSlot const& _lit) { return util::toCompactHexWithPrefix(_lit.value); },
[](TemporarySlot const& _tmp) -> std::string { return "TMP[" + _tmp.call.get().functionName.name.str() + ", " + std::to_string(_tmp.index) + "]"; },
[](JunkSlot const&) -> std::string { return "JUNK"; }
}, _slot);
}

View File

@ -135,11 +135,9 @@ Stack StackLayoutGenerator::propagateStackThroughOperation(Stack _exitStack, CFG
stack = createIdealLayout(stack, layout);
if (auto const* assignment = get_if<CFG::Assignment>(&_operation.operation))
for (auto& stackSlot: stack)
if (auto const* varSlot = get_if<VariableSlot>(&stackSlot))
if (util::findOffset(assignment->variables, *varSlot))
stackSlot = JunkSlot{};
for (auto& stackSlot: stack)
if (util::findOffset(_operation.output, stackSlot))
stackSlot = JunkSlot{};
for (StackSlot const& input: _operation.input)
stack.emplace_back(input);
@ -241,8 +239,8 @@ void StackLayoutGenerator::processEntryPoint(CFG::BasicBlock const& _entry)
{
visited.emplace(block);
yulAssert(_functionReturn.info, "");
Stack stack = _functionReturn.info->returnVariables | ranges::views::transform([](auto const& _varSlot){
return StackSlot{_varSlot};
Stack stack = _functionReturn.info->function->returnVariables | ranges::views::transform([](auto const& _var){
return StackSlot{VariableSlot{_var.name, _var.debugData}};
}) | ranges::to<Stack>;
stack.emplace_back(FunctionReturnLabelSlot{});
return stack;
@ -486,7 +484,7 @@ void StackLayoutGenerator::fixStackTooDeep(CFG::BasicBlock const& _block)
{
for (auto& slot: unreachable)
if (VariableSlot const* varSlot = get_if<VariableSlot>(&slot))
if (util::findOffset(assignment->variables, *varSlot))
if (util::findOffset(previousOperation.output, *varSlot))
{
// TODO: proper warning
std::cout << "Unreachable slot after assignment." << std::endl;

View File

@ -22,7 +22,7 @@ using namespace std;
using namespace solidity;
using namespace solidity::yul;
map<YulString, FunctionDefinition const*> FunctionDefinitionCollector::run(Block& _block)
map<YulString, FunctionDefinition const*> FunctionDefinitionCollector::run(Block const& _block)
{
FunctionDefinitionCollector functionDefinitionCollector;
functionDefinitionCollector(_block);

View File

@ -34,7 +34,7 @@ namespace solidity::yul
class FunctionDefinitionCollector: ASTWalker
{
public:
static std::map<YulString, FunctionDefinition const*> run(Block& _block);
static std::map<YulString, FunctionDefinition const*> run(Block const& _block);
private:
using ASTWalker::operator();
void operator()(FunctionDefinition const& _functionDefinition) override;

View File

@ -24,6 +24,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb
// gas irOptimized: 204081
// gas irOptimized: 203850
// gas legacy: 206126
// gas legacyOptimized: 203105

View File

@ -60,10 +60,10 @@ contract C {
// compileViaYul: also
// ----
// test_bytes() ->
// gas irOptimized: 390740
// gas irOptimized: 391331
// gas legacy: 423563
// gas legacyOptimized: 331391
// test_uint256() ->
// gas irOptimized: 546333
// gas irOptimized: 545939
// gas legacy: 591392
// gas legacyOptimized: 456137

View File

@ -26,6 +26,6 @@ contract C {
// ----
// library: L
// f() -> 8, 7, 1, 2, 7, 12
// gas irOptimized: 166704
// gas irOptimized: 166726
// gas legacy: 169475
// gas legacyOptimized: 167397

View File

@ -61,10 +61,10 @@ contract C {
// compileViaYul: also
// ----
// test_bytes() ->
// gas irOptimized: 390740
// gas irOptimized: 391331
// gas legacy: 423563
// gas legacyOptimized: 331391
// test_uint256() ->
// gas irOptimized: 546333
// gas irOptimized: 545939
// gas legacy: 591392
// gas legacyOptimized: 456137

View File

@ -53,6 +53,6 @@ contract C {
// f2() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc"
// f3() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc"
// f4() -> 0x20, 0x160, 0x1, 0x80, 0xc0, 0x2, 0x3, "abc", 0x7, 0x40, 0x2, 0x2, 0x3
// gas irOptimized: 113098
// gas irOptimized: 113136
// gas legacy: 114728
// gas legacyOptimized: 112606

View File

@ -32,6 +32,6 @@ contract C is B {
// compileViaYul: also
// ----
// test() -> 77
// gas irOptimized: 127054
// gas irOptimized: 128462
// gas legacy: 155249
// gas legacyOptimized: 111743

View File

@ -40,5 +40,5 @@ contract C is B {
// compileViaYul: also
// ----
// test() -> 5, 10
// gas irOptimized: 89080
// gas irOptimized: 89268
// gas legacy: 99137

View File

@ -21,6 +21,6 @@ contract C {
// f(uint256[][1]): 32, 32, 0 -> true
// f(uint256[][1]): 32, 32, 1, 42 -> true
// f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true
// gas irOptimized: 133946
// gas irOptimized: 133413
// gas legacy: 141900
// gas legacyOptimized: 121788

View File

@ -19,10 +19,10 @@ contract C {
// compileViaYul: also
// ----
// h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324
// gas irOptimized: 181484
// gas irOptimized: 181544
// gas legacy: 184929
// gas legacyOptimized: 181504
// i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224
// gas irOptimized: 112920
// gas irOptimized: 112957
// gas legacy: 115468
// gas legacyOptimized: 112988

View File

@ -11,6 +11,6 @@ contract C {
// compileViaYul: also
// ----
// f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg"
// gas irOptimized: 136127
// gas irOptimized: 136189
// gas legacy: 137190
// gas legacyOptimized: 136082

View File

@ -14,7 +14,7 @@ contract Test {
// compileViaYul: also
// ----
// set(uint24[3][]): 0x20, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12 -> 0x06
// gas irOptimized: 189863
// gas irOptimized: 190592
// gas legacy: 211485
// gas legacyOptimized: 206394
// data(uint256,uint256): 0x02, 0x02 -> 0x09

View File

@ -47,7 +47,7 @@ contract c {
// gas legacyOptimized: 58606
// storageEmpty -> 0
// test_long() -> 67
// gas irOptimized: 90990
// gas irOptimized: 91086
// gas legacy: 103590
// gas legacyOptimized: 101044
// storageEmpty -> 0

View File

@ -19,6 +19,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0
// gas irOptimized: 161154
// gas irOptimized: 161577
// gas legacy: 189715
// gas legacyOptimized: 184472

View File

@ -15,7 +15,7 @@ contract c {
// ----
// getLength() -> 0
// set(): 1, 2 -> true
// gas irOptimized: 110451
// gas irOptimized: 110490
// gas legacy: 110726
// gas legacyOptimized: 110567
// getLength() -> 68

View File

@ -22,7 +22,7 @@ contract c {
// compileViaYul: also
// ----
// store(uint256[9],uint8[3][]): 21, 22, 23, 24, 25, 26, 27, 28, 29, 0x140, 4, 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33 -> 32
// gas irOptimized: 651532
// gas irOptimized: 651217
// gas legacy: 694515
// gas legacyOptimized: 694013
// retrieve() -> 9, 28, 9, 28, 4, 3, 32

View File

@ -23,6 +23,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> true
// gas irOptimized: 91272
// gas irOptimized: 91314
// gas legacy: 93035
// gas legacyOptimized: 92257

View File

@ -48,6 +48,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> true
// gas irOptimized: 146336
// gas irOptimized: 146435
// gas legacy: 155961
// gas legacyOptimized: 153588

View File

@ -15,6 +15,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0
// gas irOptimized: 134523
// gas irOptimized: 134557
// gas legacy: 135313
// gas legacyOptimized: 134548

View File

@ -42,11 +42,11 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0
// gas irOptimized: 91293
// gas irOptimized: 91323
// gas legacy: 93006
// gas legacyOptimized: 92261
// g() -> 0
// h() -> 0
// gas irOptimized: 91380
// gas irOptimized: 91419
// gas legacy: 93028
// gas legacyOptimized: 92303

View File

@ -21,6 +21,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x05000000000000000000000000000000000000000000000000
// gas irOptimized: 210357
// gas irOptimized: 210566
// gas legacy: 221883
// gas legacyOptimized: 220734

View File

@ -37,12 +37,12 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x02000202
// gas irOptimized: 4682282
// gas irOptimized: 4718817
// gas legacy: 4578341
// gas legacyOptimized: 4548354
// storageEmpty -> 1
// clear() -> 0, 0
// gas irOptimized: 4506598
// gas irOptimized: 4541950
// gas legacy: 4410769
// gas legacyOptimized: 4382531
// storageEmpty -> 1

View File

@ -15,6 +15,6 @@ contract c {
// compileViaYul: also
// ----
// test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10
// gas irOptimized: 690179
// gas irOptimized: 690611
// gas legacy: 686268
// gas legacyOptimized: 685688

View File

@ -19,6 +19,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 5, 4
// gas irOptimized: 225242
// gas irOptimized: 225317
// gas legacy: 233801
// gas legacyOptimized: 232816

View File

@ -24,6 +24,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 3, 4
// gas irOptimized: 190637
// gas irOptimized: 191011
// gas legacy: 195353
// gas legacyOptimized: 192441

View File

@ -17,7 +17,7 @@ contract c {
// ----
// setData1(uint256,uint256,uint256): 10, 5, 4 ->
// copyStorageStorage() ->
// gas irOptimized: 111429
// gas irOptimized: 111477
// gas legacy: 109278
// gas legacyOptimized: 109268
// getData2(uint256): 5 -> 10, 4

View File

@ -20,6 +20,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 5, 4
// gas irOptimized: 272096
// gas irOptimized: 272118
// gas legacy: 270834
// gas legacyOptimized: 269960

View File

@ -14,6 +14,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 9, 4
// gas irOptimized: 123221
// gas irOptimized: 123293
// gas legacy: 123579
// gas legacyOptimized: 123208

View File

@ -18,6 +18,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 8, 0
// gas irOptimized: 236388
// gas irOptimized: 236614
// gas legacy: 234695
// gas legacyOptimized: 234103

View File

@ -19,7 +19,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> 4, 5
// gas irOptimized: 239059
// gas irOptimized: 239117
// gas legacy: 238736
// gas legacyOptimized: 237159
// storageEmpty -> 1

View File

@ -17,6 +17,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0x20, 2, 0x40, 0xa0, 2, 0, 1, 2, 2, 3
// gas irOptimized: 160944
// gas irOptimized: 161175
// gas legacy: 162278
// gas legacyOptimized: 159955

View File

@ -20,6 +20,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0xffffffff, 0x0000000000000000000000000a00090008000700060005000400030002000100, 0x0000000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 126407
// gas irOptimized: 127036
// gas legacy: 186406
// gas legacyOptimized: 166126

View File

@ -22,6 +22,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x04000000000000000000000000000000000000000000000000, 0x0, 0x0
// gas irOptimized: 92325
// gas irOptimized: 92314
// gas legacy: 97451
// gas legacyOptimized: 94200

View File

@ -22,6 +22,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x0
// gas irOptimized: 293911
// gas irOptimized: 293994
// gas legacy: 303653
// gas legacyOptimized: 301999

View File

@ -22,6 +22,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x00
// gas irOptimized: 273418
// gas irOptimized: 273459
// gas legacy: 276381
// gas legacyOptimized: 275453

View File

@ -38,10 +38,10 @@ contract c {
// compileViaYul: true
// ----
// test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65
// gas irOptimized: 180097
// gas irOptimized: 180271
// test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65
// gas irOptimized: 157464
// gas irOptimized: 157522
// test3(uint256[2][]): 0x20, 2, 23, 42, 23, 42 -> 2, 65
// gas irOptimized: 134984
// gas irOptimized: 135009
// test4(uint256[2][2]): 23, 42, 23, 42 -> 65
// gas irOptimized: 111483
// gas irOptimized: 111516

View File

@ -40,12 +40,12 @@ contract Test {
// compileViaYul: also
// ----
// test() -> 24
// gas irOptimized: 226186
// gas irOptimized: 226125
// gas legacy: 227133
// gas legacyOptimized: 226547
// test1() -> 3
// test2() -> 6
// test3() -> 24
// gas irOptimized: 133423
// gas irOptimized: 133375
// gas legacy: 134295
// gas legacyOptimized: 133383

View File

@ -17,4 +17,4 @@ contract C {
// compileViaYul: true
// ----
// f((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12
// gas irOptimized: 120509
// gas irOptimized: 120557

View File

@ -19,4 +19,4 @@ contract C {
// compileViaYul: true
// ----
// f() -> 10, 11, 12
// gas irOptimized: 119248
// gas irOptimized: 119272

View File

@ -23,4 +23,4 @@ contract C {
// compileViaYul: true
// ----
// f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1
// gas irOptimized: 321914
// gas irOptimized: 321698

View File

@ -26,4 +26,4 @@ contract C {
// compileViaYul: true
// ----
// f() -> 3, 3, 3, 1
// gas irOptimized: 183750
// gas irOptimized: 183630

View File

@ -15,6 +15,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 1, 2, 3
// gas irOptimized: 132265
// gas irOptimized: 132271
// gas legacy: 134619
// gas legacyOptimized: 131940

View File

@ -12,7 +12,7 @@ contract Test {
// compileViaYul: also
// ----
// set(uint24[]): 0x20, 18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 -> 18
// gas irOptimized: 99934
// gas irOptimized: 100070
// gas legacy: 103815
// gas legacyOptimized: 101614
// data(uint256): 7 -> 8

View File

@ -7,11 +7,11 @@ contract c {
// compileViaYul: also
// ----
// set(uint256): 1, 2 -> true
// gas irOptimized: 110621
// gas irOptimized: 110669
// gas legacy: 111091
// gas legacyOptimized: 110736
// set(uint256): 2, 2, 3, 4, 5 -> true
// gas irOptimized: 177590
// gas irOptimized: 177656
// gas legacy: 178021
// gas legacyOptimized: 177666
// storageEmpty -> 0

View File

@ -19,25 +19,25 @@ contract c {
// ----
// f(uint256): 0 -> 0x20, 0x00
// f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00
// gas irOptimized: 114862
// gas irOptimized: 115862
// gas legacy: 124364
// gas legacyOptimized: 119898
// f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671
// gas irOptimized: 121021
// gas irOptimized: 122326
// gas legacy: 135431
// gas legacyOptimized: 130829
// f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 127832
// gas irOptimized: 129212
// gas legacy: 142238
// gas legacyOptimized: 137518
// f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992
// gas irOptimized: 133392
// gas irOptimized: 135762
// gas legacy: 160728
// gas legacyOptimized: 152168
// f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000
// gas legacy: 59345
// gas legacyOptimized: 57279
// f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968
// gas irOptimized: 367467
// gas irOptimized: 371822
// gas legacy: 423017
// gas legacyOptimized: 406021

View File

@ -11,6 +11,6 @@ contract C {
// compileViaYul: also
// ----
// f(uint256[]): 0x20, 0x03, 0x1, 0x2, 0x3 -> 0x1
// gas irOptimized: 111103
// gas irOptimized: 111107
// gas legacy: 111565
// gas legacyOptimized: 111347

View File

@ -37,11 +37,11 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000
// gas irOptimized: 180098
// gas irOptimized: 180170
// gas legacy: 180694
// gas legacyOptimized: 180088
// g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000
// gas irOptimized: 107525
// gas irOptimized: 107675
// gas legacy: 107895
// gas legacyOptimized: 107254
// h() -> 0x40, 0x60, 0x00, 0x00

View File

@ -48,6 +48,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0xff
// gas irOptimized: 120116
// gas irOptimized: 120185
// gas legacy: 126745
// gas legacyOptimized: 123476

View File

@ -18,6 +18,6 @@ contract C {
// compileViaYul: also
// ----
// test() -> 7
// gas irOptimized: 126713
// gas irOptimized: 127161
// gas legacy: 205196
// gas legacyOptimized: 204987

View File

@ -9,7 +9,7 @@ contract c {
// compileViaYul: also
// ----
// set(): 1, 2, 3, 4, 5 -> true
// gas irOptimized: 177429
// gas irOptimized: 177486
// gas legacy: 177656
// gas legacyOptimized: 177496
// storageEmpty -> 0

View File

@ -20,6 +20,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 3
// gas irOptimized: 128887
// gas irOptimized: 129013
// gas legacy: 130307
// gas legacyOptimized: 129363

View File

@ -19,6 +19,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 1, 2, 3, 4, 5, 6, 7
// gas irOptimized: 205948
// gas irOptimized: 206305
// gas legacy: 212325
// gas legacyOptimized: 211486

View File

@ -13,6 +13,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000
// gas irOptimized: 203008
// gas irOptimized: 203101
// gas legacy: 204459
// gas legacyOptimized: 203437

View File

@ -20,6 +20,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 1, 2, 3, 4, 5, 6, 7
// gas irOptimized: 205948
// gas irOptimized: 206305
// gas legacy: 212330
// gas legacyOptimized: 211491

View File

@ -15,6 +15,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 2, 3, 4
// gas irOptimized: 118794
// gas irOptimized: 119278
// gas legacy: 126449
// gas legacyOptimized: 120902

View File

@ -20,6 +20,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> "A", 8, 4, "B"
// gas irOptimized: 128810
// gas irOptimized: 131723
// gas legacy: 121398
// gas legacyOptimized: 115494

View File

@ -18,6 +18,6 @@ contract c {
// compileViaYul: also
// ----
// test1() -> true
// gas irOptimized: 212092
// gas irOptimized: 212798
// gas legacy: 255577
// gas legacyOptimized: 248611

View File

@ -16,4 +16,4 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0, 0, 0
// gas irOptimized: 90107
// gas irOptimized: 90129

View File

@ -16,7 +16,7 @@ contract c {
// ----
// storageEmpty -> 1
// fill() ->
// gas irOptimized: 520360
// gas irOptimized: 520045
// gas legacy: 521773
// gas legacyOptimized: 517048
// storageEmpty -> 0

View File

@ -44,7 +44,7 @@ contract c {
// ----
// getLengths() -> 0, 0
// setLengths(uint256,uint256): 48, 49 ->
// gas irOptimized: 103558
// gas irOptimized: 103414
// gas legacy: 108571
// gas legacyOptimized: 100417
// getLengths() -> 48, 49

View File

@ -18,7 +18,7 @@ contract c {
// ----
// storageEmpty -> 1
// fill() -> 8
// gas irOptimized: 116558
// gas irOptimized: 116543
// gas legacy: 121756
// gas legacyOptimized: 120687
// storageEmpty -> 0

View File

@ -13,7 +13,7 @@ contract c {
// ----
// storageEmpty -> 1
// fill() ->
// gas irOptimized: 465538
// gas irOptimized: 465727
// gas legacy: 471460
// gas legacyOptimized: 467520
// storageEmpty -> 0

View File

@ -21,6 +21,6 @@ contract B {
// compileViaYul: also
// ----
// f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004
// gas irOptimized: 116423
// gas irOptimized: 117039
// gas legacy: 235167
// gas legacyOptimized: 133299

View File

@ -45,6 +45,6 @@ contract C {
// compileViaYul: also
// ----
// test() -> 5, 6, 7
// gas irOptimized: 314380
// gas irOptimized: 318994
// gas legacy: 463662
// gas legacyOptimized: 296513

View File

@ -25,7 +25,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> 1, 2, 3
// gas irOptimized: 2270841
// gas irOptimized: 2274550
// gas legacy: 2273722
// gas legacyOptimized: 2262396
// storageEmpty -> 1

View File

@ -20,7 +20,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> 38, 28, 18
// gas irOptimized: 187932
// gas irOptimized: 188881
// gas legacy: 189780
// gas legacyOptimized: 178870
// storageEmpty -> 1

View File

@ -20,7 +20,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> 20, 10
// gas irOptimized: 159134
// gas irOptimized: 159770
// gas legacy: 159459
// gas legacyOptimized: 153281
// storageEmpty -> 1

View File

@ -12,6 +12,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000
// gas irOptimized: 111672
// gas irOptimized: 112057
// gas legacy: 127309
// gas legacyOptimized: 124136

View File

@ -18,7 +18,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> true
// gas irOptimized: 184772
// gas irOptimized: 184688
// gas legacy: 229864
// gas legacyOptimized: 210964
// storageEmpty -> 1

View File

@ -17,7 +17,7 @@ contract c {
// compileViaYul: also
// ----
// test() ->
// gas irOptimized: 146901
// gas irOptimized: 145701
// gas legacy: 165363
// gas legacyOptimized: 159446
// storageEmpty -> 1

View File

@ -12,6 +12,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 109293
// gas irOptimized: 109683
// gas legacy: 126187
// gas legacyOptimized: 123261

View File

@ -18,6 +18,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 5, 4, 3, 3
// gas irOptimized: 110866
// gas irOptimized: 110854
// gas legacy: 111838
// gas legacyOptimized: 111128

View File

@ -14,6 +14,6 @@ contract C {
// compileViaYul: also
// ----
// f(uint120[]): 0x20, 3, 1, 2, 3 -> 1
// gas irOptimized: 112175
// gas irOptimized: 112223
// gas legacy: 113686
// gas legacyOptimized: 113499

View File

@ -16,6 +16,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 1, 2, 3, 4
// gas irOptimized: 91505
// gas irOptimized: 91499
// gas legacy: 92798
// gas legacyOptimized: 92062

View File

@ -22,6 +22,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 2, 3, 4, 5
// gas irOptimized: 136581
// gas irOptimized: 136629
// gas legacy: 147484
// gas legacyOptimized: 146456

View File

@ -18,6 +18,6 @@ contract c {
// compileViaYul: also
// ----
// test((uint16,uint16,uint16[3],uint16[])): 0x20, 2, 3, 0, 0, 4, 0xC0, 4, 0, 0, 5, 0, 0 -> 2, 3, 4, 5
// gas irOptimized: 138718
// gas irOptimized: 138766
// gas legacy: 144322
// gas legacyOptimized: 139171

View File

@ -17,6 +17,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0
// gas irOptimized: 178770
// gas irOptimized: 179115
// gas legacy: 218028
// gas legacyOptimized: 205124

View File

@ -15,6 +15,6 @@ contract C {
// compileViaYul: also
// ----
// f() ->
// gas irOptimized: 179269
// gas irOptimized: 179305
// gas legacy: 180620
// gas legacyOptimized: 180403

View File

@ -29,14 +29,14 @@ contract C {
// ----
// l() -> 0
// f(uint256,uint256): 42, 64 ->
// gas irOptimized: 113221
// gas irOptimized: 113236
// gas legacy: 108234
// gas legacyOptimized: 102245
// l() -> 1
// ll(uint256): 0 -> 43
// a(uint256,uint256): 0, 42 -> 64
// f(uint256,uint256): 84, 128 ->
// gas irOptimized: 117765
// gas irOptimized: 117780
// gas legacy: 107780
// gas legacyOptimized: 96331
// l() -> 2

View File

@ -23,7 +23,7 @@ contract C {
// ----
// l() -> 0
// g(uint256): 70 ->
// gas irOptimized: 189335
// gas irOptimized: 190085
// gas legacy: 184991
// gas legacyOptimized: 180608
// l() -> 70

View File

@ -26,6 +26,6 @@ contract Main {
// compileViaYul: also
// ----
// f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1
// gas irOptimized: 114323
// gas irOptimized: 114523
// gas legacy: 126852
// gas legacyOptimized: 114079

View File

@ -26,6 +26,6 @@ contract Creator {
// compileViaYul: also
// ----
// f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8
// gas irOptimized: 452561
// gas irOptimized: 454921
// gas legacy: 592626
// gas legacyOptimized: 450224

View File

@ -26,6 +26,6 @@ contract Creator {
// compileViaYul: also
// ----
// f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h"
// gas irOptimized: 307271
// gas irOptimized: 306245
// gas legacy: 429173
// gas legacyOptimized: 298384

View File

@ -19,6 +19,6 @@ contract C {
// compileViaYul: also
// ----
// f(), 2000 ether -> true
// gas irOptimized: 123029
// gas irOptimized: 123629
// gas legacy: 123226
// gas legacyOptimized: 123092

View File

@ -15,6 +15,6 @@ contract C {
// ----
// createEvent(uint256): 42 ->
// ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c
// gas irOptimized: 113763
// gas irOptimized: 113721
// gas legacy: 116393
// gas legacyOptimized: 114415

View File

@ -16,6 +16,6 @@ contract C {
// ----
// createEvent(uint256): 42 ->
// ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c
// gas irOptimized: 113763
// gas irOptimized: 113721
// gas legacy: 116393
// gas legacyOptimized: 114415

View File

@ -17,6 +17,6 @@ contract C {
// ----
// createEvent(uint256): 42 ->
// ~ emit E(uint256[][]): 0x20, 0x02, 0x40, 0xa0, 0x02, 0x2a, 0x2b, 0x02, 0x2c, 0x2d
// gas irOptimized: 183740
// gas irOptimized: 183769
// gas legacy: 187621
// gas legacyOptimized: 184551

View File

@ -19,6 +19,6 @@ contract C {
// ----
// deposit() ->
// ~ emit E(string,uint256[4]): #0xa7fb06bb999a5eb9aff9e0779953f4e1e4ce58044936c2f51c7fb879b85c08bd, #0xe755d8cc1a8cde16a2a31160dcd8017ac32d7e2f13215b29a23cdae40a78aa81
// gas irOptimized: 344935
// gas irOptimized: 343678
// gas legacy: 390742
// gas legacyOptimized: 376774

View File

@ -178,7 +178,7 @@ contract DepositContract is IDepositContract, ERC165 {
// compileViaYul: also
// ----
// constructor()
// gas irOptimized: 1624131
// gas irOptimized: 1654093
// gas legacy: 2580394
// gas legacyOptimized: 1775403
// supportsInterface(bytes4): 0x0 -> 0
@ -186,27 +186,27 @@ contract DepositContract is IDepositContract, ERC165 {
// supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id #
// supportsInterface(bytes4): 0x8564090700000000000000000000000000000000000000000000000000000000 -> true # the deposit interface id #
// get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e
// gas irOptimized: 120024
// gas irOptimized: 120295
// gas legacy: 150465
// gas legacyOptimized: 122798
// get_deposit_count() -> 0x20, 8, 0 # TODO: check balance and logs after each deposit #
// deposit(bytes,bytes,bytes,bytes32), 32 ether: 0 -> FAILURE # Empty input #
// get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e
// gas irOptimized: 120024
// gas irOptimized: 120295
// gas legacy: 150465
// gas legacyOptimized: 122798
// get_deposit_count() -> 0x20, 8, 0
// deposit(bytes,bytes,bytes,bytes32), 1 ether: 0x80, 0xe0, 0x120, 0xaa4a8d0b7d9077248630f1a4701ae9764e42271d7f22b7838778411857fd349e, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0x00f50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8 -> # txhash: 0x7085c586686d666e8bb6e9477a0f0b09565b2060a11f1c4209d3a52295033832 #
// ~ emit DepositEvent(bytes,bytes,bytes,bytes,bytes): 0xa0, 0x0100, 0x0140, 0x0180, 0x0200, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0xf50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x08, 0xca9a3b00000000000000000000000000000000000000000000000000000000, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8, 0x08, 0x00
// get_deposit_root() -> 0x2089653123d9c721215120b6db6738ba273bbc5228ac093b1f983badcdc8a438
// gas irOptimized: 120015
// gas irOptimized: 120286
// gas legacy: 150475
// gas legacyOptimized: 122811
// get_deposit_count() -> 0x20, 8, 0x0100000000000000000000000000000000000000000000000000000000000000
// deposit(bytes,bytes,bytes,bytes32), 32 ether: 0x80, 0xe0, 0x120, 0xdbd986dc85ceb382708cf90a3500f500f0a393c5ece76963ac3ed72eccd2c301, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x00344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d -> # txhash: 0x404d8e109822ce448e68f45216c12cb051b784d068fbe98317ab8e50c58304ac #
// ~ emit DepositEvent(bytes,bytes,bytes,bytes,bytes): 0xa0, 0x0100, 0x0140, 0x0180, 0x0200, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x08, 0x40597307000000000000000000000000000000000000000000000000000000, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d, 0x08, 0x0100000000000000000000000000000000000000000000000000000000000000
// get_deposit_root() -> 0x40255975859377d912c53aa853245ebd939bdd2b33a28e084babdcc1ed8238ee
// gas irOptimized: 120015
// gas irOptimized: 120286
// gas legacy: 150475
// gas legacyOptimized: 122811
// get_deposit_count() -> 0x20, 8, 0x0200000000000000000000000000000000000000000000000000000000000000

View File

@ -50,7 +50,7 @@ contract test {
// compileViaYul: also
// ----
// constructor()
// gas irOptimized: 2146563
// gas irOptimized: 2140668
// gas legacy: 2602700
// gas legacyOptimized: 1874490
// div(int256,int256): 3141592653589793238, 88714123 -> 35412542528203691288251815328
@ -58,7 +58,7 @@ contract test {
// gas legacy: 22767
// gas legacyOptimized: 22282
// exp(int256): 3141592653589793238 -> 23140692632779268978
// gas irOptimized: 25080
// gas irOptimized: 25077
// gas legacy: 25203
// gas legacyOptimized: 24357
// exp2(int256): 3141592653589793238 -> 8824977827076287620
@ -66,30 +66,30 @@ contract test {
// gas legacy: 24864
// gas legacyOptimized: 24110
// gm(int256,int256): 3141592653589793238, 88714123 -> 16694419339601
// gas irOptimized: 22742
// gas irOptimized: 22739
// gas legacy: 23228
// gas legacyOptimized: 22683
// log10(int256): 3141592653589793238 -> 4971498726941338506
// gas irOptimized: 31156
// gas irOptimized: 31171
// gas legacy: 32934
// gas legacyOptimized: 30323
// log2(int256): 3141592653589793238 -> 1651496129472318782
// gas irOptimized: 29361
// gas irOptimized: 29379
// gas legacy: 31067
// gas legacyOptimized: 28426
// mul(int256,int256): 3141592653589793238, 88714123 -> 278703637
// gas irOptimized: 22308
// gas irOptimized: 22305
// gas legacy: 22807
// gas legacyOptimized: 22295
// pow(int256,uint256): 3141592653589793238, 5 -> 306019684785281453040
// gas irOptimized: 22689
// gas irOptimized: 22686
// gas legacy: 23508
// gas legacyOptimized: 22921
// sqrt(int256): 3141592653589793238 -> 1772453850905516027
// gas irOptimized: 22337
// gas irOptimized: 22340
// gas legacy: 22802
// gas legacyOptimized: 22422
// benchmark(int256): 3141592653589793238 -> 998882724338592125, 1000000000000000000, 1000000000000000000
// gas irOptimized: 33920
// gas irOptimized: 34001
// gas legacy: 36673
// gas legacyOptimized: 34729

View File

@ -50,46 +50,46 @@ contract test {
// compileViaYul: also
// ----
// constructor()
// gas irOptimized: 1916328
// gas irOptimized: 1911724
// gas legacy: 2356230
// gas legacyOptimized: 1746528
// div(uint256,uint256): 3141592653589793238, 88714123 -> 35412542528203691288251815328
// gas irOptimized: 21925
// gas irOptimized: 21931
// gas legacy: 22497
// gas legacyOptimized: 22010
// exp(uint256): 3141592653589793238 -> 23140692632779268978
// gas irOptimized: 24850
// gas irOptimized: 24862
// gas legacy: 25104
// gas legacyOptimized: 24258
// exp2(uint256): 3141592653589793238 -> 8824977827076287620
// gas irOptimized: 24608
// gas irOptimized: 24614
// gas legacy: 24814
// gas legacyOptimized: 24062
// gm(uint256,uint256): 3141592653589793238, 88714123 -> 16694419339601
// gas irOptimized: 22844
// gas irOptimized: 22847
// gas legacy: 23269
// gas legacyOptimized: 22724
// log10(uint256): 3141592653589793238 -> 0x44fe4fc084a52b8a
// gas irOptimized: 30474
// gas irOptimized: 30297
// gas legacy: 32898
// gas legacyOptimized: 29925
// log2(uint256): 3141592653589793238 -> 1651496129472318782
// gas irOptimized: 28344
// gas irOptimized: 28170
// gas legacy: 30986
// gas legacyOptimized: 28001
// mul(uint256,uint256): 3141592653589793238, 88714123 -> 278703637
// gas irOptimized: 22001
// gas irOptimized: 22004
// gas legacy: 22604
// gas legacyOptimized: 22090
// pow(uint256,uint256): 3141592653589793238, 5 -> 306019684785281453040
// gas irOptimized: 22420
// gas irOptimized: 22411
// gas legacy: 23245
// gas legacyOptimized: 22646
// sqrt(uint256): 3141592653589793238 -> 1772453850905516027
// gas irOptimized: 22570
// gas irOptimized: 22573
// gas legacy: 22820
// gas legacyOptimized: 22440
// benchmark(uint256): 3141592653589793238 -> 998882724338592125, 1000000000000000000, 1000000000000000000
// gas irOptimized: 35080
// gas irOptimized: 35158
// gas legacy: 35385
// gas legacyOptimized: 33449

Some files were not shown because too many files have changed in this diff Show More