mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
IRGenerator: Leave IR optimization up to the caller to avoid unnecessarily doing it twice
This commit is contained in:
@@ -89,36 +89,13 @@ set<CallableDeclaration const*, ASTNode::CompareByID> collectReachableCallables(
|
||||
|
||||
}
|
||||
|
||||
tuple<string, Json::Value, string, Json::Value> IRGenerator::run(
|
||||
string IRGenerator::run(
|
||||
ContractDefinition const& _contract,
|
||||
bytes const& _cborMetadata,
|
||||
map<ContractDefinition const*, string_view const> const& _otherYulSources
|
||||
)
|
||||
{
|
||||
string ir = yul::reindent(generate(_contract, _cborMetadata, _otherYulSources));
|
||||
|
||||
yul::YulStack asmStack(
|
||||
m_evmVersion,
|
||||
m_eofVersion,
|
||||
yul::YulStack::Language::StrictAssembly,
|
||||
m_optimiserSettings,
|
||||
m_context.debugInfoSelection()
|
||||
);
|
||||
if (!asmStack.parseAndAnalyze("", ir))
|
||||
{
|
||||
string errorMessage;
|
||||
for (auto const& error: asmStack.errors())
|
||||
errorMessage += langutil::SourceReferenceFormatter::formatErrorInformation(
|
||||
*error,
|
||||
asmStack.charStream("")
|
||||
);
|
||||
solAssert(false, ir + "\n\nInvalid IR generated:\n" + errorMessage + "\n");
|
||||
}
|
||||
Json::Value irAst = asmStack.astJson();
|
||||
asmStack.optimize();
|
||||
Json::Value irOptAst = asmStack.astJson();
|
||||
|
||||
return {std::move(ir), std::move(irAst), asmStack.print(m_context.soliditySourceProvider()), std::move(irOptAst)};
|
||||
return yul::reindent(generate(_contract, _cborMetadata, _otherYulSources));
|
||||
}
|
||||
|
||||
string IRGenerator::generate(
|
||||
@@ -1116,7 +1093,6 @@ void IRGenerator::resetContext(ContractDefinition const& _contract, ExecutionCon
|
||||
m_evmVersion,
|
||||
_context,
|
||||
m_context.revertStrings(),
|
||||
m_optimiserSettings,
|
||||
m_context.sourceIndices(),
|
||||
m_context.debugInfoSelection(),
|
||||
m_context.soliditySourceProvider()
|
||||
|
||||
Reference in New Issue
Block a user