Enable for IR code generation with stack optimization > homestead.

This commit is contained in:
Daniel Kirchner 2021-08-13 00:37:23 +02:00
parent a7b137829f
commit b2c9b69de2
2 changed files with 28 additions and 17 deletions

View File

@ -139,9 +139,9 @@ public:
private: private:
bool analyzeParsed(); bool analyzeParsed();
bool analyzeParsed(yul::Object& _object); bool analyzeParsed(yul::Object& _object);
public:
void compileEVM(yul::AbstractAssembly& _assembly, bool _optimize) const; void compileEVM(yul::AbstractAssembly& _assembly, bool _optimize) const;
private:
void optimize(yul::Object& _object, bool _isCreation); void optimize(yul::Object& _object, bool _isCreation);
Language m_language = Language::Assembly; Language m_language = Language::Assembly;

View File

@ -23,6 +23,7 @@
#include <libyul/backends/evm/EVMCodeTransform.h> #include <libyul/backends/evm/EVMCodeTransform.h>
#include <libyul/backends/evm/EVMDialect.h> #include <libyul/backends/evm/EVMDialect.h>
#include <libyul/backends/evm/OptimizedEVMCodeTransform.h>
#include <libyul/Object.h> #include <libyul/Object.h>
#include <libyul/Exceptions.h> #include <libyul/Exceptions.h>
@ -62,19 +63,29 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize)
yulAssert(_object.analysisInfo, "No analysis info."); yulAssert(_object.analysisInfo, "No analysis info.");
yulAssert(_object.code, "No code."); yulAssert(_object.code, "No code.");
// We do not catch and re-throw the stack too deep exception here because it is a YulException, if (_optimize && m_dialect.evmVersion().canOverchargeGasForCall())
// which should be native to this part of the code. {
CodeTransform transform{
m_assembly, auto stackErrors = OptimizedEVMCodeTransform::run(m_assembly, *_object.analysisInfo, *_object.code, m_dialect, context);
*_object.analysisInfo, if (!stackErrors.empty())
*_object.code, BOOST_THROW_EXCEPTION(stackErrors.front());
m_dialect, }
context, else
_optimize, {
{}, // We do not catch and re-throw the stack too deep exception here because it is a YulException,
CodeTransform::UseNamedLabels::ForFirstFunctionOfEachName // which should be native to this part of the code.
}; CodeTransform transform{
transform(*_object.code); m_assembly,
if (!transform.stackErrors().empty()) *_object.analysisInfo,
BOOST_THROW_EXCEPTION(transform.stackErrors().front()); *_object.code,
m_dialect,
context,
_optimize,
{},
CodeTransform::UseNamedLabels::ForFirstFunctionOfEachName
};
transform(*_object.code);
if (!transform.stackErrors().empty())
BOOST_THROW_EXCEPTION(transform.stackErrors().front());
}
} }