Remove isCreation flag from OptimiserSettings.

This commit is contained in:
Daniel Kirchner 2022-03-07 17:39:52 +01:00
parent b57e856426
commit e0c837b33b
5 changed files with 6 additions and 13 deletions

View File

@ -411,14 +411,11 @@ map<u256, u256> const& Assembly::optimiseInternal(
if (m_tagReplacements)
return *m_tagReplacements;
assertThrow(_settings.isCreation == m_creation, OptimizerException, "Mismatching creation settings.");
// Run optimisation for sub-assemblies.
for (size_t subId = 0; subId < m_subs.size(); ++subId)
{
OptimiserSettings settings = _settings;
Assembly& sub = *m_subs[subId];
settings.isCreation = sub.isCreation();
map<u256, u256> const& subTagReplacements = sub.optimiseInternal(
settings,
JumpdestRemover::referencedTags(m_items, subId)
@ -438,7 +435,7 @@ map<u256, u256> const& Assembly::optimiseInternal(
m_items,
_tagsReferencedFromOutside,
_settings.expectedExecutionsPerDeployment,
_settings.isCreation,
isCreation(),
_settings.evmVersion
}.optimise();
@ -539,8 +536,8 @@ map<u256, u256> const& Assembly::optimiseInternal(
if (_settings.runConstantOptimiser)
ConstantOptimisationMethod::optimiseConstants(
_settings.isCreation,
_settings.isCreation ? 1 : _settings.expectedExecutionsPerDeployment,
isCreation(),
isCreation() ? 1 : _settings.expectedExecutionsPerDeployment,
_settings.evmVersion,
*this
);

View File

@ -117,7 +117,6 @@ public:
struct OptimiserSettings
{
bool isCreation = false;
bool runInliner = false;
bool runJumpdestRemover = false;
bool runPeephole = false;

View File

@ -572,8 +572,7 @@ void CompilerContext::updateSourceLocation()
evmasm::Assembly::OptimiserSettings CompilerContext::translateOptimiserSettings(OptimiserSettings const& _settings)
{
// Constructing it this way so that we notice changes in the fields.
evmasm::Assembly::OptimiserSettings asmSettings{false, false, false, false, false, false, false, m_evmVersion, 0};
asmSettings.isCreation = true;
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;

View File

@ -72,8 +72,7 @@ evmasm::Assembly::OptimiserSettings translateOptimiserSettings(
)
{
// Constructing it this way so that we notice changes in the fields.
evmasm::Assembly::OptimiserSettings asmSettings{false, false, false, false, false, false, false, _evmVersion, 0};
asmSettings.isCreation = true;
evmasm::Assembly::OptimiserSettings asmSettings{false, false, false, false, false, false, _evmVersion, 0};
asmSettings.runInliner = _settings.runInliner;
asmSettings.runJumpdestRemover = _settings.runJumpdestRemover;
asmSettings.runPeephole = _settings.runPeephole;

View File

@ -1278,7 +1278,6 @@ BOOST_AUTO_TEST_CASE(jumpdest_removal_subassemblies)
main.append(u256(8));
Assembly::OptimiserSettings settings;
settings.isCreation = false;
settings.runInliner = false;
settings.runJumpdestRemover = true;
settings.runPeephole = true;
@ -1287,7 +1286,7 @@ BOOST_AUTO_TEST_CASE(jumpdest_removal_subassemblies)
settings.runConstantOptimiser = true;
settings.evmVersion = solidity::test::CommonOptions::get().evmVersion();
settings.expectedExecutionsPerDeployment = OptimiserSettings{}.expectedExecutionsPerDeployment;
;
main.optimise(settings);
AssemblyItems expectationMain{