diff options
author | chriseth <c@ethdev.com> | 2015-05-04 16:15:41 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-05-06 18:53:17 +0800 |
commit | 9d7eb49f35f801b53960135b7c353fa64cea7439 (patch) | |
tree | 07181ef831d3a577a6fdfbfc92f8aff6dc168956 /ControlFlowGraph.h | |
parent | a2e3bcbd0c45a79a9709dc8a69858765ab904805 (diff) | |
download | dexon-solidity-9d7eb49f35f801b53960135b7c353fa64cea7439.tar dexon-solidity-9d7eb49f35f801b53960135b7c353fa64cea7439.tar.gz dexon-solidity-9d7eb49f35f801b53960135b7c353fa64cea7439.tar.bz2 dexon-solidity-9d7eb49f35f801b53960135b7c353fa64cea7439.tar.lz dexon-solidity-9d7eb49f35f801b53960135b7c353fa64cea7439.tar.xz dexon-solidity-9d7eb49f35f801b53960135b7c353fa64cea7439.tar.zst dexon-solidity-9d7eb49f35f801b53960135b7c353fa64cea7439.zip |
Gather knowledge about the state during control flow analysis.
Diffstat (limited to 'ControlFlowGraph.h')
-rw-r--r-- | ControlFlowGraph.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/ControlFlowGraph.h b/ControlFlowGraph.h index 5d16df32..4310d664 100644 --- a/ControlFlowGraph.h +++ b/ControlFlowGraph.h @@ -24,16 +24,17 @@ #pragma once #include <vector> +#include <memory> #include <libdevcore/Common.h> #include <libdevcore/Assertions.h> +#include <libevmasm/ExpressionClasses.h> namespace dev { namespace eth { -class AssemblyItem; -using AssemblyItems = std::vector<AssemblyItem>; +class KnownState; /** * Identifier for a block, coincides with the tag number of an AssemblyItem but adds a special @@ -69,14 +70,20 @@ struct BasicBlock unsigned end = 0; /// Tags pushed inside this block, with multiplicity. std::vector<BlockId> pushedTags; - /// ID of the block that always follows this one (either JUMP or flow into new block), - /// or BlockId::invalid() otherwise + /// ID of the block that always follows this one (either non-branching part of JUMPI or flow + /// into new block), or BlockId::invalid() otherwise BlockId next = BlockId::invalid(); - /// ID of the block that has to precede this one. + /// ID of the block that has to precede this one (because control flows into it). BlockId prev = BlockId::invalid(); enum class EndType { JUMP, JUMPI, STOP, HANDOVER }; EndType endType = EndType::HANDOVER; + + /// Knowledge about the state when this block is entered. Intersection of all possible ways + /// to enter this block. + std::shared_ptr<KnownState> startState; + /// Knowledge about the state at the end of this block. + std::shared_ptr<KnownState> endState; }; class ControlFlowGraph @@ -93,9 +100,14 @@ private: void splitBlocks(); void resolveNextLinks(); void removeUnusedBlocks(); + void gatherKnowledge(); void setPrevLinks(); AssemblyItems rebuildCode(); + /// @returns the corresponding BlockId if _id is a pushed jump tag, + /// and an invalid BlockId otherwise. + BlockId expressionClassToBlockId(ExpressionClasses::Id _id, ExpressionClasses& _exprClasses); + BlockId generateNewId(); unsigned m_lastUsedId = 0; |