mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Run the optimizer only once.
This commit is contained in:
parent
11a8505990
commit
3fe52d9869
@ -15,6 +15,7 @@ Compiler Features:
|
|||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
* Opcode Optimizer: Prevent the optimizer from running multiple times to avoid potential bytecode differences for referenced code.
|
||||||
* Name Resolver: Fix that when importing an aliased symbol using ``import {AliasedName} from "a.sol"`` it would use the original name of the symbol and not the aliased one.
|
* Name Resolver: Fix that when importing an aliased symbol using ``import {AliasedName} from "a.sol"`` it would use the original name of the symbol and not the aliased one.
|
||||||
* SMTChecker: Fix false negative caused by ``push`` on storage array references returned by internal functions.
|
* SMTChecker: Fix false negative caused by ``push`` on storage array references returned by internal functions.
|
||||||
* SMTChecker: Fix false positive in external calls from constructors.
|
* SMTChecker: Fix false positive in external calls from constructors.
|
||||||
|
@ -409,18 +409,21 @@ Assembly& Assembly::optimise(OptimiserSettings const& _settings)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
map<u256, u256> Assembly::optimiseInternal(
|
map<u256, u256> const& Assembly::optimiseInternal(
|
||||||
OptimiserSettings const& _settings,
|
OptimiserSettings const& _settings,
|
||||||
std::set<size_t> _tagsReferencedFromOutside
|
std::set<size_t> _tagsReferencedFromOutside
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (m_tagReplacements)
|
||||||
|
return *m_tagReplacements;
|
||||||
|
|
||||||
// Run optimisation for sub-assemblies.
|
// Run optimisation for sub-assemblies.
|
||||||
for (size_t subId = 0; subId < m_subs.size(); ++subId)
|
for (size_t subId = 0; subId < m_subs.size(); ++subId)
|
||||||
{
|
{
|
||||||
OptimiserSettings settings = _settings;
|
OptimiserSettings settings = _settings;
|
||||||
// Disable creation mode for sub-assemblies.
|
// Disable creation mode for sub-assemblies.
|
||||||
settings.isCreation = false;
|
settings.isCreation = false;
|
||||||
map<u256, u256> subTagReplacements = m_subs[subId]->optimiseInternal(
|
map<u256, u256> const& subTagReplacements = m_subs[subId]->optimiseInternal(
|
||||||
settings,
|
settings,
|
||||||
JumpdestRemover::referencedTags(m_items, subId)
|
JumpdestRemover::referencedTags(m_items, subId)
|
||||||
);
|
);
|
||||||
@ -546,7 +549,8 @@ map<u256, u256> Assembly::optimiseInternal(
|
|||||||
*this
|
*this
|
||||||
);
|
);
|
||||||
|
|
||||||
return tagReplacements;
|
m_tagReplacements = move(tagReplacements);
|
||||||
|
return *m_tagReplacements;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkerObject const& Assembly::assemble() const
|
LinkerObject const& Assembly::assemble() const
|
||||||
|
@ -165,7 +165,7 @@ protected:
|
|||||||
/// Does the same operations as @a optimise, but should only be applied to a sub and
|
/// Does the same operations as @a optimise, but should only be applied to a sub and
|
||||||
/// returns the replaced tags. Also takes an argument containing the tags of this assembly
|
/// returns the replaced tags. Also takes an argument containing the tags of this assembly
|
||||||
/// that are referenced in a super-assembly.
|
/// that are referenced in a super-assembly.
|
||||||
std::map<u256, u256> optimiseInternal(OptimiserSettings const& _settings, std::set<size_t> _tagsReferencedFromOutside);
|
std::map<u256, u256> const& optimiseInternal(OptimiserSettings const& _settings, std::set<size_t> _tagsReferencedFromOutside);
|
||||||
|
|
||||||
unsigned bytesRequired(unsigned subTagSize) const;
|
unsigned bytesRequired(unsigned subTagSize) const;
|
||||||
|
|
||||||
@ -210,6 +210,10 @@ protected:
|
|||||||
/// This map is used only for sub-assemblies which are not direct sub-assemblies (where path is having more than one value).
|
/// This map is used only for sub-assemblies which are not direct sub-assemblies (where path is having more than one value).
|
||||||
std::map<std::vector<size_t>, size_t> m_subPaths;
|
std::map<std::vector<size_t>, size_t> m_subPaths;
|
||||||
|
|
||||||
|
/// Contains the tag replacements relevant for super-assemblies.
|
||||||
|
/// If set, it means the optimizer has run and we will not run it again.
|
||||||
|
std::optional<std::map<u256, u256>> m_tagReplacements;
|
||||||
|
|
||||||
mutable LinkerObject m_assembledObject;
|
mutable LinkerObject m_assembledObject;
|
||||||
mutable std::vector<size_t> m_tagPositionsInBytecode;
|
mutable std::vector<size_t> m_tagPositionsInBytecode;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user