Remove Assembly::OptimiserSettings::translateSettings(..).

This commit is contained in:
Alexander Arlt 2022-08-16 17:47:45 +02:00
parent e57c137558
commit 4f76877753
4 changed files with 21 additions and 20 deletions

View File

@ -940,18 +940,3 @@ Assembly const* Assembly::subAssemblyById(size_t _subId) const
assertThrow(currentAssembly != this, AssemblyException, "");
return currentAssembly;
}
Assembly::OptimiserSettings Assembly::OptimiserSettings::translateSettings(frontend::OptimiserSettings const& _settings, langutil::EVMVersion const& _evmVersion)
{
// Constructing it this way so that we notice changes in the fields.
evmasm::Assembly::OptimiserSettings asmSettings{false, false, false, false, false, false, _evmVersion, 0};
asmSettings.runInliner = _settings.runInliner;
asmSettings.runJumpdestRemover = _settings.runJumpdestRemover;
asmSettings.runPeephole = _settings.runPeephole;
asmSettings.runDeduplicate = _settings.runDeduplicate;
asmSettings.runCSE = _settings.runCSE;
asmSettings.runConstantOptimiser = _settings.runConstantOptimiser;
asmSettings.expectedExecutionsPerDeployment = _settings.expectedExecutionsPerDeployment;
asmSettings.evmVersion = _evmVersion;
return asmSettings;
}

View File

@ -128,8 +128,6 @@ public:
/// This specifies an estimate on how often each opcode in this assembly will be executed,
/// i.e. use a small value to optimise for size and a large value to optimise for runtime gas usage.
size_t expectedExecutionsPerDeployment = frontend::OptimiserSettings{}.expectedExecutionsPerDeployment;
static OptimiserSettings translateSettings(frontend::OptimiserSettings const& _settings, langutil::EVMVersion const& _evmVersion);
};
/// Modify and return the current assembly such that creation and execution gas usage

View File

@ -574,7 +574,17 @@ void CompilerContext::updateSourceLocation()
evmasm::Assembly::OptimiserSettings CompilerContext::translateOptimiserSettings(OptimiserSettings const& _settings)
{
return evmasm::Assembly::OptimiserSettings::translateSettings(_settings, m_evmVersion);
// Constructing it this way so that we notice changes in the fields.
evmasm::Assembly::OptimiserSettings asmSettings{false, false, false, false, false, false, m_evmVersion, 0};
asmSettings.runInliner = _settings.runInliner;
asmSettings.runJumpdestRemover = _settings.runJumpdestRemover;
asmSettings.runPeephole = _settings.runPeephole;
asmSettings.runDeduplicate = _settings.runDeduplicate;
asmSettings.runCSE = _settings.runCSE;
asmSettings.runConstantOptimiser = _settings.runConstantOptimiser;
asmSettings.expectedExecutionsPerDeployment = _settings.expectedExecutionsPerDeployment;
asmSettings.evmVersion = m_evmVersion;
return asmSettings;
}
evmasm::AssemblyItem CompilerContext::FunctionCompilationQueue::entryLabel(

View File

@ -686,8 +686,16 @@ bool CompilerStack::compile(State _stopAfter)
string const evmSourceName = m_evmAssemblyJson.begin()->first;
Json::Value const evmJson = m_evmAssemblyJson.begin()->second;
evmasm::Assembly::OptimiserSettings optimiserSettings =
evmasm::Assembly::OptimiserSettings::translateSettings(m_optimiserSettings, m_evmVersion);
// todo: remove code duplication.
evmasm::Assembly::OptimiserSettings optimiserSettings{false, false, false, false, false, false, m_evmVersion, 0};
optimiserSettings.runInliner = m_optimiserSettings.runInliner;
optimiserSettings.runJumpdestRemover = m_optimiserSettings.runJumpdestRemover;
optimiserSettings.runPeephole = m_optimiserSettings.runPeephole;
optimiserSettings.runDeduplicate = m_optimiserSettings.runDeduplicate;
optimiserSettings.runCSE = m_optimiserSettings.runCSE;
optimiserSettings.runConstantOptimiser = m_optimiserSettings.runConstantOptimiser;
optimiserSettings.expectedExecutionsPerDeployment = m_optimiserSettings.expectedExecutionsPerDeployment;
optimiserSettings.evmVersion = m_evmVersion;
m_contracts[evmSourceName].evmAssembly = evmasm::Assembly::loadFromAssemblyJSON(m_evmAssemblyJson[evmSourceName]);
if (m_optimiserSettings.enabled)