Merge pull request #11252 from ethereum/simplifySemanticInfo

Remove semantic information function for assembly items.
This commit is contained in:
chriseth 2021-04-14 10:35:36 +02:00 committed by GitHub
commit 60d43ecf28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 20 deletions

View File

@ -82,7 +82,12 @@ bool Inliner::isInlineCandidate(size_t _tag, ranges::span<AssemblyItem const> _i
{
assertThrow(_items.size() > 0, OptimizerException, "");
if (_items.back() != Instruction::JUMP && !SemanticInformation::terminatesControlFlow(_items.back()))
if (_items.back().type() != Operation)
return false;
if (
_items.back() != Instruction::JUMP &&
!SemanticInformation::terminatesControlFlow(_items.back().instruction())
)
return false;
// Never inline tags that reference themselves.
@ -213,7 +218,7 @@ optional<AssemblyItem> Inliner::shouldInline(size_t _tag, AssemblyItem const& _j
// Inline small blocks, if the jump to it is ordinary or the blockExit is a terminating instruction.
if (
_jump.getJumpType() == AssemblyItem::JumpType::Ordinary ||
SemanticInformation::terminatesControlFlow(blockExit)
SemanticInformation::terminatesControlFlow(blockExit.instruction())
)
{
static AssemblyItems const jumpPattern = {

View File

@ -135,14 +135,6 @@ bool SemanticInformation::altersControlFlow(AssemblyItem const& _item)
}
}
bool SemanticInformation::terminatesControlFlow(AssemblyItem const& _item)
{
if (_item.type() != Operation)
return false;
else
return terminatesControlFlow(_item.instruction());
}
bool SemanticInformation::terminatesControlFlow(Instruction _instruction)
{
switch (_instruction)
@ -158,14 +150,6 @@ bool SemanticInformation::terminatesControlFlow(Instruction _instruction)
}
}
bool SemanticInformation::reverts(AssemblyItem const& _item)
{
if (_item.type() != Operation)
return false;
else
return reverts(_item.instruction());
}
bool SemanticInformation::reverts(Instruction _instruction)
{
switch (_instruction)

View File

@ -55,9 +55,7 @@ struct SemanticInformation
static bool isSwapInstruction(AssemblyItem const& _item);
static bool isJumpInstruction(AssemblyItem const& _item);
static bool altersControlFlow(AssemblyItem const& _item);
static bool terminatesControlFlow(AssemblyItem const& _item);
static bool terminatesControlFlow(Instruction _instruction);
static bool reverts(AssemblyItem const& _item);
static bool reverts(Instruction _instruction);
/// @returns false if the value put on the stack by _item depends on anything else than
/// the information in the current block header, memory, storage or stack.