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:
bool analyzeParsed();
bool analyzeParsed(yul::Object& _object);
public:
void compileEVM(yul::AbstractAssembly& _assembly, bool _optimize) const;
private:
void optimize(yul::Object& _object, bool _isCreation);
Language m_language = Language::Assembly;

View File

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