Use DOT for testing.

This commit is contained in:
Daniel Kirchner 2021-07-06 17:47:09 +02:00
parent d039949c53
commit 69f33581ad
9 changed files with 789 additions and 202 deletions

View File

@ -283,6 +283,9 @@ void StackLayoutGenerator::processEntryPoint(CFG::BasicBlock const& _entry)
// In particular we can visit backwards starting from ``block`` and mark all entries to-be-visited-
// again until we hit ``target``.
toVisit.emplace_front(block);
// Since we are likely to change the entry layout of ``target``, we also visit its entries again.
for (CFG::BasicBlock const* entry: target->entries)
visited.erase(entry);
util::BreadthFirstSearch<CFG::BasicBlock const*>{{block}}.run(
[&visited, target = target](CFG::BasicBlock const* _block, auto _addChild) {
visited.erase(_block);

View File

@ -29,6 +29,12 @@
#include <libsolutil/AnsiColorized.h>
#include <libsolutil/Visitor.h>
#include <range/v3/view/reverse.hpp>
#ifdef ISOLTEST
#include <boost/process.hpp>
#endif
using namespace solidity;
using namespace solidity::util;
using namespace solidity::langutil;
@ -82,9 +88,13 @@ public:
m_stream(_stream), m_stackLayout(_stackLayout)
{
}
void operator()(CFG::BasicBlock const& _block)
void operator()(CFG::BasicBlock const& _block, bool _isMainEntry = true)
{
getBlockId(_block);
if (_isMainEntry)
{
m_stream << "Entry [label=\"Entry\"];\n";
m_stream << "Entry -> Block" << getBlockId(_block) << ";\n";
}
while (!m_blocksToPrint.empty())
{
CFG::BasicBlock const* block = *m_blocksToPrint.begin();
@ -97,7 +107,8 @@ public:
CFG::FunctionInfo const& _info
)
{
m_stream << m_indent << "function " << _info.function.name.str() << "(";
m_stream << "FunctionEntry_" << _info.function.name.str() << " [label=\"";
m_stream << "function " << _info.function.name.str() << "(";
m_stream << joinHumanReadable(_info.parameters | ranges::views::transform(variableSlotToString));
m_stream << ")";
if (!_info.returnVariables.empty())
@ -105,32 +116,45 @@ public:
m_stream << " -> ";
m_stream << joinHumanReadable(_info.returnVariables | ranges::views::transform(variableSlotToString));
}
m_stream << ":\n";
ScopedSaveAndRestore linePrefixRestore(m_indent, m_indent + " ");
(*this)(*_info.entry);
m_stream << "\\l\\\n";
Stack functionEntryStack = {FunctionReturnLabelSlot{}};
functionEntryStack += _info.parameters | ranges::views::reverse;
m_stream << stackToString(functionEntryStack) << "\"];\n";
m_stream << "FunctionEntry_" << _info.function.name.str() << " -> Block" << getBlockId(*_info.entry) << ";\n";
(*this)(*_info.entry, false);
}
private:
void printBlock(CFG::BasicBlock const& _block)
{
m_stream << m_indent << "Block " << getBlockId(_block) << ":\n";
ScopedSaveAndRestore linePrefixRestore(m_indent, m_indent + " ");
m_stream << "Block" << getBlockId(_block) << " [label=\"\\\n";
m_stream << m_indent << "Entries: ";
if (_block.entries.empty())
m_stream << "None\n";
else
m_stream << joinHumanReadable(_block.entries | ranges::views::transform([&](auto const* _entry) {
return to_string(getBlockId(*_entry));
})) << "\n";
m_stream << m_indent << "Entry Layout: " << stackToString(m_stackLayout.blockInfos.at(&_block).entryLayout) << "\n";
// Verify that the entries of this block exit into this block.
for (auto const& entry: _block.entries)
std::visit(util::GenericVisitor{
[&](CFG::BasicBlock::Jump const& _jump)
{
soltestAssert(_jump.target == &_block, "Invalid control flow graph.");
},
[&](CFG::BasicBlock::ConditionalJump const& _conditionalJump)
{
soltestAssert(
_conditionalJump.zero == &_block || _conditionalJump.nonZero == &_block,
"Invalid control flow graph."
);
},
[&](auto const&)
{
soltestAssert(false, "Invalid control flow graph.");
}
}, entry->exit);
auto const& blockInfo = m_stackLayout.blockInfos.at(&_block);
m_stream << stackToString(blockInfo.entryLayout) << "\\l\\\n";
for (auto const& operation: _block.operations)
{
m_stream << m_indent;
m_stream << stackToString(m_stackLayout.operationEntryLayout.at(&operation)) << " >> ";
auto entryLayout = m_stackLayout.operationEntryLayout.at(&operation);
m_stream << stackToString(m_stackLayout.operationEntryLayout.at(&operation)) << "\\l\\\n";
std::visit(util::GenericVisitor{
[&](CFG::FunctionCall const& _call) {
m_stream << _call.function.get().name.str();
@ -145,36 +169,53 @@ private:
m_stream << ")";
}
}, operation.operation);
m_stream << "\n";
m_stream << "\\l\\\n";
soltestAssert(operation.input.size() <= entryLayout.size(), "Invalid Stack Layout.");
for (size_t i = 0; i < operation.input.size(); ++i)
entryLayout.pop_back();
entryLayout += operation.output;
m_stream << stackToString(entryLayout) << "\\l\\\n";
}
m_stream << m_indent << "Exit Layout: " << stackToString(m_stackLayout.blockInfos.at(&_block).exitLayout) << "\n";
m_stream << stackToString(blockInfo.exitLayout) << "\\l\\\n";
m_stream << "\"];\n";
std::visit(util::GenericVisitor{
[&](CFG::BasicBlock::MainExit const&)
{
m_stream << m_indent << "MainExit\n";
m_stream << "Block" << getBlockId(_block) << "Exit [label=\"MainExit\"];\n";
m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit;\n";
},
[&](CFG::BasicBlock::Jump const& _jump)
{
m_stream << m_indent << "Jump" << (_jump.backwards ? " (backwards): " : ": ") << getBlockId(*_jump.target);
m_stream << " (Entry Layout: " << stackToString(m_stackLayout.blockInfos.at(_jump.target).entryLayout) << ")\n";
m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit [arrowhead=none];\n";
m_stream << "Block" << getBlockId(_block) << "Exit [label=\"";
if (_jump.backwards)
m_stream << "Backwards";
m_stream << "Jump\" shape=oval];\n";
m_stream << "Block" << getBlockId(_block) << "Exit -> Block" << getBlockId(*_jump.target) << ";\n";
},
[&](CFG::BasicBlock::ConditionalJump const& _conditionalJump)
{
m_stream << m_indent << "ConditionalJump " << stackSlotToString(_conditionalJump.condition) << ":\n";
m_stream << m_indent << " NonZero: " << getBlockId(*_conditionalJump.nonZero);
m_stream << " (Entry Layout: " << stackToString(m_stackLayout.blockInfos.at(_conditionalJump.nonZero).entryLayout) << ")\n";
m_stream << m_indent << " Zero: " << getBlockId(*_conditionalJump.zero);
m_stream << " (Entry Layout: " << stackToString(m_stackLayout.blockInfos.at(_conditionalJump.zero).entryLayout) << ")\n";
m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit;\n";
m_stream << "Block" << getBlockId(_block) << "Exit [label=\"{ ";
m_stream << stackSlotToString(_conditionalJump.condition);
m_stream << "| { <0> Zero | <1> NonZero }}\" shape=Mrecord];\n";
m_stream << "Block" << getBlockId(_block);
m_stream << "Exit:0 -> Block" << getBlockId(*_conditionalJump.zero) << ";\n";
m_stream << "Block" << getBlockId(_block);
m_stream << "Exit:1 -> Block" << getBlockId(*_conditionalJump.nonZero) << ";\n";
},
[&](CFG::BasicBlock::FunctionReturn const& _return)
{
m_stream << m_indent << "FunctionReturn of " << _return.info->function.name.str() << "\n";
m_stream << "Block" << getBlockId(_block) << "Exit [label=\"FunctionReturn[" << _return.info->function.name.str() << "]\"];\n";
m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit;\n";
},
[&](CFG::BasicBlock::Terminated const&)
{
m_stream << m_indent << "Terminated\n";
m_stream << "Block" << getBlockId(_block) << "Exit [label=\"Terminated\"];\n";
m_stream << "Block" << getBlockId(_block) << " -> Block" << getBlockId(_block) << "Exit;\n";
}
}, _block.exit);
m_stream << "\n";
}
size_t getBlockId(CFG::BasicBlock const& _block)
{
@ -186,7 +227,6 @@ private:
}
std::ostream& m_stream;
StackLayout const& m_stackLayout;
std::string m_indent;
std::map<CFG::BasicBlock const*, size_t> m_blockIds;
size_t m_blockCount = 0;
std::list<CFG::BasicBlock const*> m_blocksToPrint;
@ -208,11 +248,40 @@ TestCase::TestResult StackLayoutGeneratorTest::run(ostream& _stream, string cons
std::unique_ptr<CFG> cfg = ControlFlowGraphBuilder::build(*analysisInfo, *m_dialect, *object->code);
StackLayout stackLayout = StackLayoutGenerator::run(*cfg);
StackLayoutPrinter{output, stackLayout}(*cfg->entry);
output << "digraph CFG {\nnodesep=0.7;\nnode[shape=box];\n\n";
StackLayoutPrinter printer{output, stackLayout};
printer(*cfg->entry);
for (auto function: cfg->functions)
StackLayoutPrinter{output, stackLayout}(cfg->functionInfo.at(function));
printer(cfg->functionInfo.at(function));
output << "}\n";
m_obtainedResult = output.str();
return checkResult(_stream, _linePrefix, _formatted);
auto result = checkResult(_stream, _linePrefix, _formatted);
#ifdef ISOLTEST
char* graphDisplayer = nullptr;
if (result == TestResult::Failure)
graphDisplayer = getenv("ISOLTEST_DISPLAY_GRAPHS_FAILURE");
else if (result == TestResult::Success)
graphDisplayer = getenv("ISOLTEST_DISPLAY_GRAPHS_SUCCESS");
if (graphDisplayer)
{
if (result == TestResult::Success)
std::cout << std::endl << m_source << std::endl;
boost::process::opstream pipe;
boost::process::child child(graphDisplayer, boost::process::std_in < pipe);
pipe << output.str();
pipe.flush();
pipe.pipe().close();
if (result == TestResult::Success)
child.wait();
else
child.detach();
}
#endif
return result;
}

View File

@ -0,0 +1,318 @@
{
function f(a, b) -> c {
for { let x := 42 } lt(x, a) {
x := add(x, 1)
if calldataload(x)
{
sstore(0, x)
c := 0x21
leave
sstore(0x01, 0x0101)
}
sstore(0xFF, 0xFFFF)
}
{
switch mload(x)
case 0 {
sstore(a, b)
break
sstore(a, b)
}
case 1 {
sstore(0x04, x)
leave
sstore(a, 0x0505)
}
case 2 {
sstore(x, 0x06)
c := 42
revert(0, 0)
sstore(0x07, 0x0707)
}
case 3 {
sstore(0x08, 0x0808)
}
default {
if mload(b) {
return(0, 0)
sstore(0x09, 0x0909)
}
sstore(0x0A, 0x0A0A)
}
sstore(0x0B, 0x0B0B)
}
sstore(0x0C, 0x0C0C)
if sload(0x0D) {
c := 0x424242
}
}
pop(f(1,2))
}
// ----
// digraph CFG {
// nodesep=0.7;
// node[shape=box];
//
// Entry [label="Entry"];
// Entry -> Block0;
// Block0 [label="\
// [ ]\l\
// [ RET[f] 0x02 0x01 ]\l\
// f\l\
// [ TMP[f, 0] ]\l\
// [ TMP[f, 0] ]\l\
// pop\l\
// [ ]\l\
// [ ]\l\
// "];
// Block0Exit [label="MainExit"];
// Block0 -> Block0Exit;
//
// FunctionEntry_f [label="function f(a, b) -> c\l\
// [ RET b a ]"];
// FunctionEntry_f -> Block1;
// Block1 [label="\
// [ c RET a b ]\l\
// [ c RET a b 0x2a ]\l\
// Assignment(x)\l\
// [ c RET a b x ]\l\
// [ c RET a b x ]\l\
// "];
// Block1 -> Block1Exit [arrowhead=none];
// Block1Exit [label="Jump" shape=oval];
// Block1Exit -> Block2;
//
// Block2 [label="\
// [ c RET a b x ]\l\
// [ c RET a b x a x ]\l\
// lt\l\
// [ c RET a b x TMP[lt, 0] ]\l\
// [ c RET a b x TMP[lt, 0] ]\l\
// "];
// Block2 -> Block2Exit;
// Block2Exit [label="{ TMP[lt, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block2Exit:0 -> Block3;
// Block2Exit:1 -> Block4;
//
// Block3 [label="\
// [ c RET JUNK JUNK JUNK ]\l\
// [ c RET 0x0c0c 0x0c ]\l\
// sstore\l\
// [ c RET ]\l\
// [ c RET 0x0d ]\l\
// sload\l\
// [ c RET TMP[sload, 0] ]\l\
// [ c RET TMP[sload, 0] ]\l\
// "];
// Block3 -> Block3Exit;
// Block3Exit [label="{ TMP[sload, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block3Exit:0 -> Block5;
// Block3Exit:1 -> Block6;
//
// Block4 [label="\
// [ c RET a b x ]\l\
// [ c RET a b x x ]\l\
// mload\l\
// [ c RET a b x TMP[mload, 0] ]\l\
// [ c RET a b x TMP[mload, 0] ]\l\
// Assignment(GHOST[0])\l\
// [ c RET a b x GHOST[0] ]\l\
// [ c RET a b x GHOST[0] GHOST[0] 0x00 ]\l\
// eq\l\
// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\
// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\
// "];
// Block4 -> Block4Exit;
// Block4Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block4Exit:0 -> Block7;
// Block4Exit:1 -> Block8;
//
// Block5 [label="\
// [ c RET ]\l\
// [ c RET ]\l\
// "];
// Block5Exit [label="FunctionReturn[f]"];
// Block5 -> Block5Exit;
//
// Block6 [label="\
// [ JUNK RET ]\l\
// [ RET 0x424242 ]\l\
// Assignment(c)\l\
// [ RET c ]\l\
// [ c RET ]\l\
// "];
// Block6 -> Block6Exit [arrowhead=none];
// Block6Exit [label="Jump" shape=oval];
// Block6Exit -> Block5;
//
// Block7 [label="\
// [ c RET a b x GHOST[0] ]\l\
// [ c RET a b x GHOST[0] GHOST[0] 0x01 ]\l\
// eq\l\
// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\
// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\
// "];
// Block7 -> Block7Exit;
// Block7Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block7Exit:0 -> Block9;
// Block7Exit:1 -> Block10;
//
// Block8 [label="\
// [ c RET a b JUNK JUNK ]\l\
// [ c RET b a ]\l\
// sstore\l\
// [ c RET ]\l\
// [ c RET ]\l\
// "];
// Block8 -> Block8Exit [arrowhead=none];
// Block8Exit [label="Jump" shape=oval];
// Block8Exit -> Block3;
//
// Block9 [label="\
// [ c RET a b x GHOST[0] ]\l\
// [ c RET a b x GHOST[0] GHOST[0] 0x02 ]\l\
// eq\l\
// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\
// [ c RET a b x GHOST[0] TMP[eq, 0] ]\l\
// "];
// Block9 -> Block9Exit;
// Block9Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block9Exit:0 -> Block11;
// Block9Exit:1 -> Block12;
//
// Block10 [label="\
// [ c RET JUNK JUNK x JUNK ]\l\
// [ c RET x 0x04 ]\l\
// sstore\l\
// [ c RET ]\l\
// [ c RET ]\l\
// "];
// Block10Exit [label="FunctionReturn[f]"];
// Block10 -> Block10Exit;
//
// Block11 [label="\
// [ c RET a b x GHOST[0] ]\l\
// [ c RET a b 0x01 x GHOST[0] 0x03 ]\l\
// eq\l\
// [ c RET a b 0x01 x TMP[eq, 0] ]\l\
// [ c RET a b 0x01 x TMP[eq, 0] ]\l\
// "];
// Block11 -> Block11Exit;
// Block11Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block11Exit:0 -> Block13;
// Block11Exit:1 -> Block14;
//
// Block12 [label="\
// [ JUNK JUNK JUNK JUNK x JUNK ]\l\
// [ 0x06 x ]\l\
// sstore\l\
// [ ]\l\
// [ 0x2a ]\l\
// Assignment(c)\l\
// [ c ]\l\
// [ 0x00 0x00 ]\l\
// revert\l\
// [ ]\l\
// [ ]\l\
// "];
// Block12Exit [label="Terminated"];
// Block12 -> Block12Exit;
//
// Block13 [label="\
// [ c RET a b 0x01 x ]\l\
// [ c RET a b 0x01 x b ]\l\
// mload\l\
// [ c RET a b 0x01 x TMP[mload, 0] ]\l\
// [ c RET a b 0x01 x TMP[mload, 0] ]\l\
// "];
// Block13 -> Block13Exit;
// Block13Exit [label="{ TMP[mload, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block13Exit:0 -> Block15;
// Block13Exit:1 -> Block16;
//
// Block14 [label="\
// [ c RET a b 0x01 x ]\l\
// [ c RET a b 0x01 x 0x0808 0x08 ]\l\
// sstore\l\
// [ c RET a b 0x01 x ]\l\
// [ c RET a b 0x01 x ]\l\
// "];
// Block14 -> Block14Exit [arrowhead=none];
// Block14Exit [label="Jump" shape=oval];
// Block14Exit -> Block17;
//
// Block15 [label="\
// [ c RET a b 0x01 x ]\l\
// [ c RET a b 0x01 x 0x0a0a 0x0a ]\l\
// sstore\l\
// [ c RET a b 0x01 x ]\l\
// [ c RET a b 0x01 x ]\l\
// "];
// Block15 -> Block15Exit [arrowhead=none];
// Block15Exit [label="Jump" shape=oval];
// Block15Exit -> Block17;
//
// Block16 [label="\
// [ JUNK JUNK JUNK JUNK JUNK JUNK ]\l\
// [ 0x00 0x00 ]\l\
// return\l\
// [ ]\l\
// [ ]\l\
// "];
// Block16Exit [label="Terminated"];
// Block16 -> Block16Exit;
//
// Block17 [label="\
// [ c RET a b 0x01 x ]\l\
// [ c RET a b 0x01 x 0x0b0b 0x0b ]\l\
// sstore\l\
// [ c RET a b 0x01 x ]\l\
// [ c RET a b 0x01 x ]\l\
// "];
// Block17 -> Block17Exit [arrowhead=none];
// Block17Exit [label="Jump" shape=oval];
// Block17Exit -> Block18;
//
// Block18 [label="\
// [ c RET a b 0x01 x ]\l\
// [ c RET a b 0x01 x ]\l\
// add\l\
// [ c RET a b TMP[add, 0] ]\l\
// [ c RET a b TMP[add, 0] ]\l\
// Assignment(x)\l\
// [ c RET a b x ]\l\
// [ c RET x b a x ]\l\
// calldataload\l\
// [ c RET x b a TMP[calldataload, 0] ]\l\
// [ c RET x b a TMP[calldataload, 0] ]\l\
// "];
// Block18 -> Block18Exit;
// Block18Exit [label="{ TMP[calldataload, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block18Exit:0 -> Block19;
// Block18Exit:1 -> Block20;
//
// Block19 [label="\
// [ c RET x b a ]\l\
// [ c RET x b a 0xffff 0xff ]\l\
// sstore\l\
// [ c RET x b a ]\l\
// [ c RET x b a ]\l\
// "];
// Block19 -> Block19Exit [arrowhead=none];
// Block19Exit [label="BackwardsJump" shape=oval];
// Block19Exit -> Block2;
//
// Block20 [label="\
// [ JUNK RET x JUNK JUNK ]\l\
// [ RET x 0x00 ]\l\
// sstore\l\
// [ RET ]\l\
// [ RET 0x21 ]\l\
// Assignment(c)\l\
// [ RET c ]\l\
// [ c RET ]\l\
// "];
// Block20Exit [label="FunctionReturn[f]"];
// Block20 -> Block20Exit;
//
// }

View File

@ -9,41 +9,83 @@
sstore(0x06, 0x0506)
}
// ----
// Block 0:
// Entries: None
// Entry Layout: [ ]
// [ 0x0404 0x01 ] >> Assignment(x)
// [ 0x0404 x 0x02 ] >> Assignment(y)
// [ 0x0404 x x 0x01 ] >> sstore
// [ 0x0404 x 0x0202 0x02 ] >> sstore
// Exit Layout: [ 0x0404 x ]
// Jump: 1 (Entry Layout: [ 0x0404 0x0404 x ])
// Block 1:
// Entries: 0, 2
// Entry Layout: [ 0x0404 0x0404 x ]
// [ 0x0404 0x0404 x 0x0303 x ] >> lt
// Exit Layout: [ 0x0404 0x0404 x TMP[lt, 0] ]
// ConditionalJump TMP[lt, 0]:
// NonZero: 3 (Entry Layout: [ 0x0404 0x0404 x ])
// Zero: 4 (Entry Layout: [ JUNK JUNK JUNK ])
// Block 2:
// Entries: 3
// Entry Layout: [ 0x0404 0x0404 x ]
// [ 0x0404 0x0404 x ] >> add
// [ 0x0404 TMP[add, 0] ] >> Assignment(x)
// Exit Layout: [ 0x0404 x ]
// Jump (backwards): 1 (Entry Layout: [ 0x0404 0x0404 x ])
// Block 3:
// Entries: 1
// Entry Layout: [ 0x0404 0x0404 x ]
// [ 0x0404 0x0404 x 0x0505 0x05 ] >> sstore
// [ 0x0404 0x0404 x x ] >> sload
// [ 0x0404 0x0404 x TMP[sload, 0] ] >> Assignment(y)
// Exit Layout: [ 0x0404 0x0404 x ]
// Jump: 2 (Entry Layout: [ 0x0404 0x0404 x ])
// Block 4:
// Entries: 1
// Entry Layout: [ JUNK JUNK JUNK ]
// [ 0x0506 0x06 ] >> sstore
// Exit Layout: [ ]
// MainExit
// digraph CFG {
// nodesep=0.7;
// node[shape=box];
//
// Entry [label="Entry"];
// Entry -> Block0;
// Block0 [label="\
// [ ]\l\
// [ 0x0404 0x0404 0x01 ]\l\
// Assignment(x)\l\
// [ 0x0404 0x0404 x ]\l\
// [ 0x0404 0x0404 x 0x02 ]\l\
// Assignment(y)\l\
// [ 0x0404 0x0404 x y ]\l\
// [ 0x0404 0x0404 x x 0x01 ]\l\
// sstore\l\
// [ 0x0404 0x0404 x ]\l\
// [ 0x0404 0x0404 x 0x0202 0x02 ]\l\
// sstore\l\
// [ 0x0404 0x0404 x ]\l\
// [ 0x0404 0x0404 x ]\l\
// "];
// Block0 -> Block0Exit [arrowhead=none];
// Block0Exit [label="Jump" shape=oval];
// Block0Exit -> Block1;
//
// Block1 [label="\
// [ 0x0404 0x0404 x ]\l\
// [ 0x0404 0x0404 x 0x0303 x ]\l\
// lt\l\
// [ 0x0404 0x0404 x TMP[lt, 0] ]\l\
// [ 0x0404 0x0404 x TMP[lt, 0] ]\l\
// "];
// Block1 -> Block1Exit;
// Block1Exit [label="{ TMP[lt, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block1Exit:0 -> Block2;
// Block1Exit:1 -> Block3;
//
// Block2 [label="\
// [ JUNK JUNK JUNK ]\l\
// [ 0x0506 0x06 ]\l\
// sstore\l\
// [ ]\l\
// [ ]\l\
// "];
// Block2Exit [label="MainExit"];
// Block2 -> Block2Exit;
//
// Block3 [label="\
// [ 0x0404 0x0404 x ]\l\
// [ 0x0404 0x0404 x 0x0505 0x05 ]\l\
// sstore\l\
// [ 0x0404 0x0404 x ]\l\
// [ 0x0404 0x0404 x x ]\l\
// sload\l\
// [ 0x0404 0x0404 x TMP[sload, 0] ]\l\
// [ 0x0404 0x0404 x TMP[sload, 0] ]\l\
// Assignment(y)\l\
// [ 0x0404 0x0404 x y ]\l\
// [ 0x0404 0x0404 x ]\l\
// "];
// Block3 -> Block3Exit [arrowhead=none];
// Block3Exit [label="Jump" shape=oval];
// Block3Exit -> Block4;
//
// Block4 [label="\
// [ 0x0404 0x0404 x ]\l\
// [ 0x0404 0x0404 x ]\l\
// add\l\
// [ 0x0404 TMP[add, 0] ]\l\
// [ 0x0404 TMP[add, 0] ]\l\
// Assignment(x)\l\
// [ 0x0404 x ]\l\
// [ 0x0404 x ]\l\
// "];
// Block4 -> Block4Exit [arrowhead=none];
// Block4Exit [label="BackwardsJump" shape=oval];
// Block4Exit -> Block1;
//
// }

View File

@ -19,46 +19,99 @@
h(y)
}
// ----
// Block 0:
// Entries: None
// Entry Layout: [ ]
// [ RET[h] RET[h] RET[i] ] >> i
// [ RET[h] RET[h] TMP[i, 0] TMP[i, 1] ] >> Assignment(x, y)
// [ RET[h] y RET[h] x ] >> h
// [ RET[h] y ] >> h
// Exit Layout: [ ]
// MainExit
// function f(a, b) -> r:
// Block 0:
// Entries: None
// Entry Layout: [ RET a b ]
// [ RET a b a ] >> add
// [ RET a TMP[add, 0] ] >> Assignment(x)
// [ RET a x ] >> sub
// [ RET TMP[sub, 0] ] >> Assignment(r)
// Exit Layout: [ r RET ]
// FunctionReturn of f
// function g():
// Block 0:
// Entries: None
// Entry Layout: [ RET ]
// [ RET 0x0101 0x01 ] >> sstore
// Exit Layout: [ RET ]
// FunctionReturn of g
// function h(x):
// Block 0:
// Entries: None
// Entry Layout: [ RET RET[h] RET[f] 0x00 x ]
// [ RET RET[h] RET[f] 0x00 x ] >> f
// [ RET RET[h] TMP[f, 0] ] >> h
// [ RET RET[g] ] >> g
// Exit Layout: [ RET ]
// FunctionReturn of h
// function i() -> v, w:
// Block 0:
// Entries: None
// Entry Layout: [ RET ]
// [ RET 0x0202 ] >> Assignment(v)
// [ v RET 0x0303 ] >> Assignment(w)
// Exit Layout: [ v w RET ]
// FunctionReturn of i
// digraph CFG {
// nodesep=0.7;
// node[shape=box];
//
// Entry [label="Entry"];
// Entry -> Block0;
// Block0 [label="\
// [ ]\l\
// [ RET[h] RET[h] RET[i] ]\l\
// i\l\
// [ RET[h] RET[h] TMP[i, 0] TMP[i, 1] ]\l\
// [ RET[h] RET[h] TMP[i, 0] TMP[i, 1] ]\l\
// Assignment(x, y)\l\
// [ RET[h] RET[h] x y ]\l\
// [ RET[h] y RET[h] x ]\l\
// h\l\
// [ RET[h] y ]\l\
// [ RET[h] y ]\l\
// h\l\
// [ ]\l\
// [ ]\l\
// "];
// Block0Exit [label="MainExit"];
// Block0 -> Block0Exit;
//
// FunctionEntry_f [label="function f(a, b) -> r\l\
// [ RET b a ]"];
// FunctionEntry_f -> Block1;
// Block1 [label="\
// [ RET a b ]\l\
// [ RET a b a ]\l\
// add\l\
// [ RET a TMP[add, 0] ]\l\
// [ RET a TMP[add, 0] ]\l\
// Assignment(x)\l\
// [ RET a x ]\l\
// [ RET a x ]\l\
// sub\l\
// [ RET TMP[sub, 0] ]\l\
// [ RET TMP[sub, 0] ]\l\
// Assignment(r)\l\
// [ RET r ]\l\
// [ r RET ]\l\
// "];
// Block1Exit [label="FunctionReturn[f]"];
// Block1 -> Block1Exit;
//
// FunctionEntry_g [label="function g()\l\
// [ RET ]"];
// FunctionEntry_g -> Block2;
// Block2 [label="\
// [ RET ]\l\
// [ RET 0x0101 0x01 ]\l\
// sstore\l\
// [ RET ]\l\
// [ RET ]\l\
// "];
// Block2Exit [label="FunctionReturn[g]"];
// Block2 -> Block2Exit;
//
// FunctionEntry_h [label="function h(x)\l\
// [ RET x ]"];
// FunctionEntry_h -> Block3;
// Block3 [label="\
// [ RET RET[h] RET[f] 0x00 x ]\l\
// [ RET RET[h] RET[f] 0x00 x ]\l\
// f\l\
// [ RET RET[h] TMP[f, 0] ]\l\
// [ RET RET[h] TMP[f, 0] ]\l\
// h\l\
// [ RET ]\l\
// [ RET RET[g] ]\l\
// g\l\
// [ RET ]\l\
// [ RET ]\l\
// "];
// Block3Exit [label="FunctionReturn[h]"];
// Block3 -> Block3Exit;
//
// FunctionEntry_i [label="function i() -> v, w\l\
// [ RET ]"];
// FunctionEntry_i -> Block4;
// Block4 [label="\
// [ RET ]\l\
// [ RET 0x0202 ]\l\
// Assignment(v)\l\
// [ RET v ]\l\
// [ v RET 0x0303 ]\l\
// Assignment(w)\l\
// [ v RET w ]\l\
// [ v w RET ]\l\
// "];
// Block4Exit [label="FunctionReturn[i]"];
// Block4 -> Block4Exit;
//
// }

View File

@ -6,24 +6,46 @@
sstore(0x03, 0x003)
}
// ----
// Block 0:
// Entries: None
// Entry Layout: [ ]
// [ 0x0101 0x01 ] >> sstore
// [ 0x00 ] >> calldataload
// Exit Layout: [ TMP[calldataload, 0] ]
// ConditionalJump TMP[calldataload, 0]:
// NonZero: 1 (Entry Layout: [ ])
// Zero: 2 (Entry Layout: [ ])
// Block 1:
// Entries: 0
// Entry Layout: [ ]
// [ 0x0202 0x02 ] >> sstore
// Exit Layout: [ ]
// Jump: 2 (Entry Layout: [ ])
// Block 2:
// Entries: 0, 1
// Entry Layout: [ ]
// [ 0x03 0x03 ] >> sstore
// Exit Layout: [ ]
// MainExit
// digraph CFG {
// nodesep=0.7;
// node[shape=box];
//
// Entry [label="Entry"];
// Entry -> Block0;
// Block0 [label="\
// [ ]\l\
// [ 0x0101 0x01 ]\l\
// sstore\l\
// [ ]\l\
// [ 0x00 ]\l\
// calldataload\l\
// [ TMP[calldataload, 0] ]\l\
// [ TMP[calldataload, 0] ]\l\
// "];
// Block0 -> Block0Exit;
// Block0Exit [label="{ TMP[calldataload, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block0Exit:0 -> Block1;
// Block0Exit:1 -> Block2;
//
// Block1 [label="\
// [ ]\l\
// [ 0x03 0x03 ]\l\
// sstore\l\
// [ ]\l\
// [ ]\l\
// "];
// Block1Exit [label="MainExit"];
// Block1 -> Block1Exit;
//
// Block2 [label="\
// [ ]\l\
// [ 0x0202 0x02 ]\l\
// sstore\l\
// [ ]\l\
// [ ]\l\
// "];
// Block2 -> Block2Exit [arrowhead=none];
// Block2Exit [label="Jump" shape=oval];
// Block2Exit -> Block1;
//
// }

View File

@ -1,8 +1,17 @@
{
}
// ----
// Block 0:
// Entries: None
// Entry Layout: [ ]
// Exit Layout: [ ]
// MainExit
// digraph CFG {
// nodesep=0.7;
// node[shape=box];
//
// Entry [label="Entry"];
// Entry -> Block0;
// Block0 [label="\
// [ ]\l\
// [ ]\l\
// "];
// Block0Exit [label="MainExit"];
// Block0 -> Block0Exit;
//
// }

View File

@ -16,48 +16,92 @@
sstore(0x0404, y)
}
// ----
// Block 0:
// Entries: None
// Entry Layout: [ ]
// [ 0x0101 ] >> Assignment(x)
// [ x 0x0202 ] >> Assignment(y)
// [ y x 0x0303 ] >> Assignment(z)
// [ y z x ] >> sload
// [ y z TMP[sload, 0] ] >> Assignment(GHOST[0])
// [ y z GHOST[0] GHOST[0] 0x00 ] >> eq
// Exit Layout: [ y z GHOST[0] TMP[eq, 0] ]
// ConditionalJump TMP[eq, 0]:
// NonZero: 1 (Entry Layout: [ y JUNK JUNK ])
// Zero: 2 (Entry Layout: [ y z GHOST[0] ])
// Block 1:
// Entries: 0
// Entry Layout: [ y JUNK JUNK ]
// [ y 0x42 ] >> Assignment(x)
// Exit Layout: [ y ]
// Jump: 3 (Entry Layout: [ y ])
// Block 2:
// Entries: 0
// Entry Layout: [ y z GHOST[0] ]
// [ y z GHOST[0] 0x01 ] >> eq
// Exit Layout: [ y z TMP[eq, 0] ]
// ConditionalJump TMP[eq, 0]:
// NonZero: 4 (Entry Layout: [ JUNK JUNK ])
// Zero: 5 (Entry Layout: [ y z ])
// Block 3:
// Entries: 1, 4, 5
// Entry Layout: [ y ]
// [ y 0x0404 ] >> sstore
// Exit Layout: [ ]
// MainExit
// Block 4:
// Entries: 2
// Entry Layout: [ JUNK JUNK ]
// [ 0x42 ] >> Assignment(y)
// Exit Layout: [ y ]
// Jump: 3 (Entry Layout: [ y ])
// Block 5:
// Entries: 2
// Entry Layout: [ y z ]
// [ y z z ] >> sstore
// Exit Layout: [ y ]
// Jump: 3 (Entry Layout: [ y ])
// digraph CFG {
// nodesep=0.7;
// node[shape=box];
//
// Entry [label="Entry"];
// Entry -> Block0;
// Block0 [label="\
// [ ]\l\
// [ 0x0101 ]\l\
// Assignment(x)\l\
// [ x ]\l\
// [ x 0x0202 ]\l\
// Assignment(y)\l\
// [ x y ]\l\
// [ y x 0x0303 ]\l\
// Assignment(z)\l\
// [ y x z ]\l\
// [ y z x ]\l\
// sload\l\
// [ y z TMP[sload, 0] ]\l\
// [ y z TMP[sload, 0] ]\l\
// Assignment(GHOST[0])\l\
// [ y z GHOST[0] ]\l\
// [ y z GHOST[0] GHOST[0] 0x00 ]\l\
// eq\l\
// [ y z GHOST[0] TMP[eq, 0] ]\l\
// [ y z GHOST[0] TMP[eq, 0] ]\l\
// "];
// Block0 -> Block0Exit;
// Block0Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block0Exit:0 -> Block1;
// Block0Exit:1 -> Block2;
//
// Block1 [label="\
// [ y z GHOST[0] ]\l\
// [ y z GHOST[0] 0x01 ]\l\
// eq\l\
// [ y z TMP[eq, 0] ]\l\
// [ y z TMP[eq, 0] ]\l\
// "];
// Block1 -> Block1Exit;
// Block1Exit [label="{ TMP[eq, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block1Exit:0 -> Block3;
// Block1Exit:1 -> Block4;
//
// Block2 [label="\
// [ y JUNK JUNK ]\l\
// [ y 0x42 ]\l\
// Assignment(x)\l\
// [ y x ]\l\
// [ y ]\l\
// "];
// Block2 -> Block2Exit [arrowhead=none];
// Block2Exit [label="Jump" shape=oval];
// Block2Exit -> Block5;
//
// Block3 [label="\
// [ y z ]\l\
// [ y z z ]\l\
// sstore\l\
// [ y ]\l\
// [ y ]\l\
// "];
// Block3 -> Block3Exit [arrowhead=none];
// Block3Exit [label="Jump" shape=oval];
// Block3Exit -> Block5;
//
// Block4 [label="\
// [ JUNK JUNK ]\l\
// [ 0x42 ]\l\
// Assignment(y)\l\
// [ y ]\l\
// [ y ]\l\
// "];
// Block4 -> Block4Exit [arrowhead=none];
// Block4Exit [label="Jump" shape=oval];
// Block4Exit -> Block5;
//
// Block5 [label="\
// [ y ]\l\
// [ y 0x0404 ]\l\
// sstore\l\
// [ ]\l\
// [ ]\l\
// "];
// Block5Exit [label="MainExit"];
// Block5 -> Block5Exit;
//
// }

View File

@ -8,17 +8,44 @@
sstore(x,y)
}
// ----
// Block 0:
// Entries: None
// Entry Layout: [ ]
// [ 0x00 ] >> calldataload
// [ TMP[calldataload, 0] ] >> Assignment(x)
// [ 0x02 ] >> calldataload
// [ TMP[calldataload, 0] ] >> Assignment(y)
// [ 0x03 ] >> calldataload
// [ TMP[calldataload, 0] ] >> Assignment(x)
// [ x 0x04 ] >> calldataload
// [ x TMP[calldataload, 0] ] >> Assignment(y)
// [ y x ] >> sstore
// Exit Layout: [ ]
// MainExit
// digraph CFG {
// nodesep=0.7;
// node[shape=box];
//
// Entry [label="Entry"];
// Entry -> Block0;
// Block0 [label="\
// [ ]\l\
// [ 0x00 ]\l\
// calldataload\l\
// [ TMP[calldataload, 0] ]\l\
// [ TMP[calldataload, 0] ]\l\
// Assignment(x)\l\
// [ x ]\l\
// [ 0x02 ]\l\
// calldataload\l\
// [ TMP[calldataload, 0] ]\l\
// [ TMP[calldataload, 0] ]\l\
// Assignment(y)\l\
// [ y ]\l\
// [ 0x03 ]\l\
// calldataload\l\
// [ TMP[calldataload, 0] ]\l\
// [ TMP[calldataload, 0] ]\l\
// Assignment(x)\l\
// [ x ]\l\
// [ x 0x04 ]\l\
// calldataload\l\
// [ x TMP[calldataload, 0] ]\l\
// [ x TMP[calldataload, 0] ]\l\
// Assignment(y)\l\
// [ x y ]\l\
// [ y x ]\l\
// sstore\l\
// [ ]\l\
// [ ]\l\
// "];
// Block0Exit [label="MainExit"];
// Block0 -> Block0Exit;
//
// }