Remove semantic information function for assembly items.

This commit is contained in:
chriseth 2021-04-13 18:34:16 +02:00
parent 282c389cfc
commit 6dba5f5c2b
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, ""); 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; return false;
// Never inline tags that reference themselves. // 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. // Inline small blocks, if the jump to it is ordinary or the blockExit is a terminating instruction.
if ( if (
_jump.getJumpType() == AssemblyItem::JumpType::Ordinary || _jump.getJumpType() == AssemblyItem::JumpType::Ordinary ||
SemanticInformation::terminatesControlFlow(blockExit) SemanticInformation::terminatesControlFlow(blockExit.instruction())
) )
{ {
static AssemblyItems const jumpPattern = { 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) bool SemanticInformation::terminatesControlFlow(Instruction _instruction)
{ {
switch (_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) bool SemanticInformation::reverts(Instruction _instruction)
{ {
switch (_instruction) switch (_instruction)

View File

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