From 6dba5f5c2b7ef355173eab1715840ea04e9e0516 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 13 Apr 2021 18:34:16 +0200 Subject: [PATCH] Remove semantic information function for assembly items. --- libevmasm/Inliner.cpp | 9 +++++++-- libevmasm/SemanticInformation.cpp | 16 ---------------- libevmasm/SemanticInformation.h | 2 -- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/libevmasm/Inliner.cpp b/libevmasm/Inliner.cpp index 1e910fa60..d0f1a06f5 100644 --- a/libevmasm/Inliner.cpp +++ b/libevmasm/Inliner.cpp @@ -82,7 +82,12 @@ bool Inliner::isInlineCandidate(size_t _tag, ranges::span _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 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 = { diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index a6f8d7a9f..cd16185c4 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -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) diff --git a/libevmasm/SemanticInformation.h b/libevmasm/SemanticInformation.h index 679766e66..8ba2743c4 100644 --- a/libevmasm/SemanticInformation.h +++ b/libevmasm/SemanticInformation.h @@ -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.