diff --git a/libyul/backends/evm/ssa/CodeTransform.cpp b/libyul/backends/evm/ssa/CodeTransform.cpp index cfa20b2806c0..0ca2da5cd870 100644 --- a/libyul/backends/evm/ssa/CodeTransform.cpp +++ b/libyul/backends/evm/ssa/CodeTransform.cpp @@ -235,7 +235,7 @@ void CodeTransform::operator()(InstId _instId, StackData const& _operationInputL yulAssert(m_stack.size() >= _inst.inputs.size()); for (auto const& [stackEntry, input]: ranges::views::zip( m_stack | ranges::views::take_last(_inst.inputs.size()), - _inst.inputs + _inst.inputs | ranges::views::reverse )) yulAssert(stackEntry.isValue() && stackEntry.value() == input); diff --git a/libyul/backends/evm/ssa/SSACFGBuilder.cpp b/libyul/backends/evm/ssa/SSACFGBuilder.cpp index f055f6e0e525..5fa479d3e796 100644 --- a/libyul/backends/evm/ssa/SSACFGBuilder.cpp +++ b/libyul/backends/evm/ssa/SSACFGBuilder.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -235,7 +236,7 @@ void SSACFGBuilder::operator()(Switch const& _switch) return m_graph.makeBuiltinCallWithProjections( m_currentBlock, SSACFG::BuiltinCall{*equalityBuiltinHandle, {}}, - {m_graph.newLiteral(debugDataOf(_case), _case.value->value.value()), expression}, + {expression, m_graph.newLiteral(debugDataOf(_case), _case.value->value.value())}, static_cast(equalityBuiltin.numReturns), debugDataOf(_case) ); @@ -477,10 +478,13 @@ InstId SSACFGBuilder::visitFunctionCall(FunctionCall const& _call) yulAssert(std::holds_alternative(arg)); literalArguments.emplace_back(std::get(arg)); } + // Arguments must be evaluated from right to left, according to Yul specification std::vector inputs; for (auto&& [idx, arg]: _call.arguments | ranges::views::enumerate | ranges::views::reverse) if (!builtin.literalArgument(idx).has_value()) inputs.emplace_back(std::visit(*this, arg)); + // But we want to store them in the original order + ranges::reverse(inputs); canContinue = builtin.controlFlowSideEffects.canContinue; return m_graph.makeBuiltinCallWithProjections( m_currentBlock, @@ -497,9 +501,12 @@ InstId SSACFGBuilder::visitFunctionCall(FunctionCall const& _call) auto const calleeIt = m_functionRegistry.find(&function); yulAssert(calleeIt != m_functionRegistry.end(), "Called function has no registered graph id."); canContinue = m_sideEffects.functionSideEffects().at(calleeIt->second.definition).canContinue; + // Arguments must be evaluated from right to left, according to Yul specification std::vector inputs; for (auto const& arg: _call.arguments | ranges::views::reverse) inputs.emplace_back(std::visit(*this, arg)); + // But we want to store them in the original order + ranges::reverse(inputs); return m_graph.makeCallWithProjections( m_currentBlock, SSACFG::Call{calleeIt->second.id, canContinue, function.numReturns}, diff --git a/libyul/backends/evm/ssa/StackLayoutGenerator.cpp b/libyul/backends/evm/ssa/StackLayoutGenerator.cpp index 9b8434791ed2..f55bc10349a0 100644 --- a/libyul/backends/evm/ssa/StackLayoutGenerator.cpp +++ b/libyul/backends/evm/ssa/StackLayoutGenerator.cpp @@ -251,7 +251,10 @@ void StackLayoutGenerator::visitBlock(SSACFG::BlockId const& _blockId) requiredStackTop.emplace_back(Slot::makeFunctionCallReturnLabel(*callSiteID)); } } - requiredStackTop += _inst.inputs | ranges::views::transform([this](InstId const& _id) { return StackSlot::makeValue(m_cfg, _id); }); + requiredStackTop += + _inst.inputs + | ranges::views::reverse + | ranges::views::transform([this](InstId const& _id) { return StackSlot::makeValue(m_cfg, _id); }); for (StackType::Depth depth{0}; depth < stack.size(); ++depth.value) if ( diff --git a/libyul/backends/evm/ssa/io/Printer.cpp b/libyul/backends/evm/ssa/io/Printer.cpp index 1ea3c605e548..42ef52adf15d 100644 --- a/libyul/backends/evm/ssa/io/Printer.cpp +++ b/libyul/backends/evm/ssa/io/Printer.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -74,7 +73,7 @@ void printBuiltinOperands( _out << ' '; auto litIt = payload.literalArguments.begin(); - auto valIt = _inst.inputs.rbegin(); + auto valIt = _inst.inputs.begin(); for (std::size_t i = 0; i < builtin.numParameters; ++i) { if (i > 0) @@ -86,7 +85,7 @@ void printBuiltinOperands( } else { - yulAssert(valIt != _inst.inputs.rend()); + yulAssert(valIt != _inst.inputs.end()); _out << formatValueRef(*valIt++); } } @@ -111,12 +110,12 @@ void printCallOperands( _out << ' '; bool first = true; - for (auto it = _inst.inputs.rbegin(); it != _inst.inputs.rend(); ++it) + for (auto const input: _inst.inputs) { if (!first) _out << ", "; first = false; - _out << formatValueRef(*it); + _out << formatValueRef(input); } } diff --git a/test/cmdlineTests/standard_yul_cfg_json_export/output.json b/test/cmdlineTests/standard_yul_cfg_json_export/output.json index d457c56a3f50..a025c49d598b 100644 --- a/test/cmdlineTests/standard_yul_cfg_json_export/output.json +++ b/test/cmdlineTests/standard_yul_cfg_json_export/output.json @@ -25,8 +25,8 @@ }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -75,17 +75,17 @@ }, { "in": [ - "v7", + "v0", "v8", - "v0" + "v7" ], "op": "codecopy", "out": [] }, { "in": [ - "v7", - "v0" + "v0", + "v7" ], "op": "return", "out": [] @@ -146,8 +146,8 @@ }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -161,8 +161,8 @@ }, { "in": [ - "0x04", - "v4" + "v4", + "0x04" ], "op": "lt", "out": [ @@ -227,8 +227,8 @@ }, { "in": [ - "v8", - "0xe0" + "0xe0", + "v8" ], "op": "shr", "out": [ @@ -237,8 +237,8 @@ }, { "in": [ - "v10", - "0x26121ff0" + "0x26121ff0", + "v10" ], "op": "eq", "out": [ @@ -328,8 +328,8 @@ }, { "in": [ - "v17", - "v18" + "v18", + "v17" ], "op": "add", "out": [ @@ -338,8 +338,8 @@ }, { "in": [ - "0x00", - "v19" + "v19", + "0x00" ], "op": "slt", "out": [ @@ -383,16 +383,16 @@ "instructions": [ { "in": [ - "0x2a", - "v0" + "v0", + "0x2a" ], "op": "mstore", "out": [] }, { "in": [ - "0x20", - "v0" + "v0", + "0x20" ], "op": "return", "out": [] @@ -489,8 +489,8 @@ }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -539,17 +539,17 @@ }, { "in": [ - "v7", + "v0", "v8", - "v0" + "v7" ], "op": "codecopy", "out": [] }, { "in": [ - "v7", - "v0" + "v0", + "v7" ], "op": "return", "out": [] @@ -610,8 +610,8 @@ }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -625,8 +625,8 @@ }, { "in": [ - "0x04", - "v4" + "v4", + "0x04" ], "op": "lt", "out": [ @@ -691,8 +691,8 @@ }, { "in": [ - "v8", - "0xe0" + "0xe0", + "v8" ], "op": "shr", "out": [ @@ -701,8 +701,8 @@ }, { "in": [ - "v10", - "0x26121ff0" + "0x26121ff0", + "v10" ], "op": "eq", "out": [ @@ -792,8 +792,8 @@ }, { "in": [ - "v17", - "v18" + "v18", + "v17" ], "op": "add", "out": [ @@ -802,8 +802,8 @@ }, { "in": [ - "0x00", - "v19" + "v19", + "0x00" ], "op": "slt", "out": [ @@ -862,8 +862,8 @@ }, { "in": [ - "v23", - "v0" + "v0", + "v23" ], "op": "add", "out": [ @@ -872,8 +872,8 @@ }, { "in": [ - "v0", - "v32" + "v32", + "v0" ], "op": "lt", "out": [ @@ -882,8 +882,8 @@ }, { "in": [ - "0xffffffffffffffff", - "v32" + "v32", + "0xffffffffffffffff" ], "op": "gt", "out": [ @@ -892,8 +892,8 @@ }, { "in": [ - "v33", - "v35" + "v35", + "v33" ], "op": "or", "out": [ @@ -954,17 +954,17 @@ }, { "in": [ - "v23", + "v0", "v49", - "v0" + "v23" ], "op": "datacopy", "out": [] }, { "in": [ - "v0", - "v32" + "v32", + "v0" ], "op": "sub", "out": [ @@ -973,9 +973,9 @@ }, { "in": [ - "v59", + "0x00", "v0", - "0x00" + "v59" ], "op": "create", "out": [ @@ -1044,8 +1044,8 @@ }, { "in": [ - "0x026121ff", - "0xe4" + "0xe4", + "0x026121ff" ], "op": "shl", "out": [ @@ -1054,16 +1054,16 @@ }, { "in": [ - "v71", - "v68" + "v68", + "v71" ], "op": "mstore", "out": [] }, { "in": [ - "0x01", - "0xa0" + "0xa0", + "0x01" ], "op": "shl", "out": [ @@ -1072,8 +1072,8 @@ }, { "in": [ - "0x01", - "v76" + "v76", + "0x01" ], "op": "sub", "out": [ @@ -1082,8 +1082,8 @@ }, { "in": [ - "v77", - "v60" + "v60", + "v77" ], "op": "and", "out": [ @@ -1099,12 +1099,12 @@ }, { "in": [ - "0x20", + "v83", + "v82", "v68", "0x04", "v68", - "v82", - "v83" + "0x20" ], "op": "staticcall", "out": [ @@ -1220,16 +1220,16 @@ }, { "in": [ - "phi146", - "v145" + "v145", + "phi146" ], "op": "mstore", "out": [] }, { "in": [ - "0x20", - "v145" + "v145", + "0x20" ], "op": "return", "out": [] @@ -1263,8 +1263,8 @@ }, { "in": [ - "v96", - "0x20" + "0x20", + "v96" ], "op": "gt", "out": [ @@ -1318,8 +1318,8 @@ }, { "in": [ - "0x1f", - "phi101" + "phi101", + "0x1f" ], "op": "add", "out": [ @@ -1328,8 +1328,8 @@ }, { "in": [ - "v100", - "v104" + "v104", + "v100" ], "op": "and", "out": [ @@ -1338,8 +1338,8 @@ }, { "in": [ - "v105", - "v68" + "v68", + "v105" ], "op": "add", "out": [ @@ -1348,8 +1348,8 @@ }, { "in": [ - "v68", - "v113" + "v113", + "v68" ], "op": "lt", "out": [ @@ -1358,8 +1358,8 @@ }, { "in": [ - "0xffffffffffffffff", - "v113" + "v113", + "0xffffffffffffffff" ], "op": "gt", "out": [ @@ -1368,8 +1368,8 @@ }, { "in": [ - "v114", - "v115" + "v115", + "v114" ], "op": "or", "out": [ @@ -1431,16 +1431,16 @@ "instructions": [ { "in": [ - "v113", - "0x40" + "0x40", + "v113" ], "op": "mstore", "out": [] }, { "in": [ - "phi101", - "v68" + "v68", + "phi101" ], "op": "add", "out": [ @@ -1449,8 +1449,8 @@ }, { "in": [ - "v68", - "v135" + "v135", + "v68" ], "op": "sub", "out": [ @@ -1459,8 +1459,8 @@ }, { "in": [ - "0x20", - "v136" + "v136", + "0x20" ], "op": "slt", "out": [ @@ -1558,8 +1558,8 @@ "instructions": [ { "in": [ - "0x4e487b71", - "0xe0" + "0xe0", + "0x4e487b71" ], "op": "shl", "out": [ @@ -1568,24 +1568,24 @@ }, { "in": [ - "v2", - "0x00" + "0x00", + "v2" ], "op": "mstore", "out": [] }, { "in": [ - "0x41", - "0x04" + "0x04", + "0x41" ], "op": "mstore", "out": [] }, { "in": [ - "0x24", - "0x00" + "0x00", + "0x24" ], "op": "revert", "out": [] @@ -1629,9 +1629,9 @@ }, { "in": [ - "v2", + "v1", "0x00", - "v1" + "v2" ], "op": "returndatacopy", "out": [] @@ -1645,8 +1645,8 @@ }, { "in": [ - "v5", - "v1" + "v1", + "v5" ], "op": "revert", "out": [] @@ -1717,8 +1717,8 @@ }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -1767,17 +1767,17 @@ }, { "in": [ - "v7", + "v0", "v8", - "v0" + "v7" ], "op": "codecopy", "out": [] }, { "in": [ - "v7", - "v0" + "v0", + "v7" ], "op": "return", "out": [] @@ -1838,8 +1838,8 @@ }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -1853,8 +1853,8 @@ }, { "in": [ - "0x04", - "v4" + "v4", + "0x04" ], "op": "lt", "out": [ @@ -1919,8 +1919,8 @@ }, { "in": [ - "v8", - "0xe0" + "0xe0", + "v8" ], "op": "shr", "out": [ @@ -1929,8 +1929,8 @@ }, { "in": [ - "v10", - "0x26121ff0" + "0x26121ff0", + "v10" ], "op": "eq", "out": [ @@ -2020,8 +2020,8 @@ }, { "in": [ - "v17", - "v18" + "v18", + "v17" ], "op": "add", "out": [ @@ -2030,8 +2030,8 @@ }, { "in": [ - "0x00", - "v19" + "v19", + "0x00" ], "op": "slt", "out": [ @@ -2075,16 +2075,16 @@ "instructions": [ { "in": [ - "0x2a", - "v0" + "v0", + "0x2a" ], "op": "mstore", "out": [] }, { "in": [ - "0x20", - "v0" + "v0", + "0x20" ], "op": "return", "out": [] diff --git a/test/cmdlineTests/strict_asm_yul_cfg_json_export/output b/test/cmdlineTests/strict_asm_yul_cfg_json_export/output index 8ec19f13b241..7c014ce4c2df 100644 --- a/test/cmdlineTests/strict_asm_yul_cfg_json_export/output +++ b/test/cmdlineTests/strict_asm_yul_cfg_json_export/output @@ -25,8 +25,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -75,17 +75,17 @@ Yul Control Flow Graph: }, { "in": [ - "v7", + "v0", "v8", - "v0" + "v7" ], "op": "codecopy", "out": [] }, { "in": [ - "v7", - "v0" + "v0", + "v7" ], "op": "return", "out": [] @@ -146,8 +146,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -161,8 +161,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x04", - "v4" + "v4", + "0x04" ], "op": "lt", "out": [ @@ -227,8 +227,8 @@ Yul Control Flow Graph: }, { "in": [ - "v8", - "0xe0" + "0xe0", + "v8" ], "op": "shr", "out": [ @@ -237,8 +237,8 @@ Yul Control Flow Graph: }, { "in": [ - "v10", - "0x26121ff0" + "0x26121ff0", + "v10" ], "op": "eq", "out": [ @@ -328,8 +328,8 @@ Yul Control Flow Graph: }, { "in": [ - "v17", - "v18" + "v18", + "v17" ], "op": "add", "out": [ @@ -338,8 +338,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x00", - "v19" + "v19", + "0x00" ], "op": "slt", "out": [ @@ -383,16 +383,16 @@ Yul Control Flow Graph: "instructions": [ { "in": [ - "0x2a", - "v0" + "v0", + "0x2a" ], "op": "mstore", "out": [] }, { "in": [ - "0x20", - "v0" + "v0", + "0x20" ], "op": "return", "out": [] diff --git a/test/cmdlineTests/yul_cfg_json_export/output b/test/cmdlineTests/yul_cfg_json_export/output index 08d7bb6dd9d9..6907a76af792 100644 --- a/test/cmdlineTests/yul_cfg_json_export/output +++ b/test/cmdlineTests/yul_cfg_json_export/output @@ -24,8 +24,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -74,17 +74,17 @@ Yul Control Flow Graph: }, { "in": [ - "v7", + "v0", "v8", - "v0" + "v7" ], "op": "codecopy", "out": [] }, { "in": [ - "v7", - "v0" + "v0", + "v7" ], "op": "return", "out": [] @@ -145,8 +145,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -160,8 +160,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x04", - "v4" + "v4", + "0x04" ], "op": "lt", "out": [ @@ -226,8 +226,8 @@ Yul Control Flow Graph: }, { "in": [ - "v8", - "0xe0" + "0xe0", + "v8" ], "op": "shr", "out": [ @@ -236,8 +236,8 @@ Yul Control Flow Graph: }, { "in": [ - "v10", - "0x26121ff0" + "0x26121ff0", + "v10" ], "op": "eq", "out": [ @@ -327,8 +327,8 @@ Yul Control Flow Graph: }, { "in": [ - "v17", - "v18" + "v18", + "v17" ], "op": "add", "out": [ @@ -337,8 +337,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x00", - "v19" + "v19", + "0x00" ], "op": "slt", "out": [ @@ -382,16 +382,16 @@ Yul Control Flow Graph: "instructions": [ { "in": [ - "0x2a", - "v0" + "v0", + "0x2a" ], "op": "mstore", "out": [] }, { "in": [ - "0x20", - "v0" + "v0", + "0x20" ], "op": "return", "out": [] @@ -489,8 +489,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -539,17 +539,17 @@ Yul Control Flow Graph: }, { "in": [ - "v7", + "v0", "v8", - "v0" + "v7" ], "op": "codecopy", "out": [] }, { "in": [ - "v7", - "v0" + "v0", + "v7" ], "op": "return", "out": [] @@ -610,8 +610,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -625,8 +625,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x04", - "v4" + "v4", + "0x04" ], "op": "lt", "out": [ @@ -691,8 +691,8 @@ Yul Control Flow Graph: }, { "in": [ - "v8", - "0xe0" + "0xe0", + "v8" ], "op": "shr", "out": [ @@ -701,8 +701,8 @@ Yul Control Flow Graph: }, { "in": [ - "v10", - "0x26121ff0" + "0x26121ff0", + "v10" ], "op": "eq", "out": [ @@ -792,8 +792,8 @@ Yul Control Flow Graph: }, { "in": [ - "v17", - "v18" + "v18", + "v17" ], "op": "add", "out": [ @@ -802,8 +802,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x00", - "v19" + "v19", + "0x00" ], "op": "slt", "out": [ @@ -862,8 +862,8 @@ Yul Control Flow Graph: }, { "in": [ - "v23", - "v0" + "v0", + "v23" ], "op": "add", "out": [ @@ -872,8 +872,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "v32" + "v32", + "v0" ], "op": "lt", "out": [ @@ -882,8 +882,8 @@ Yul Control Flow Graph: }, { "in": [ - "0xffffffffffffffff", - "v32" + "v32", + "0xffffffffffffffff" ], "op": "gt", "out": [ @@ -892,8 +892,8 @@ Yul Control Flow Graph: }, { "in": [ - "v33", - "v35" + "v35", + "v33" ], "op": "or", "out": [ @@ -954,17 +954,17 @@ Yul Control Flow Graph: }, { "in": [ - "v23", + "v0", "v49", - "v0" + "v23" ], "op": "datacopy", "out": [] }, { "in": [ - "v0", - "v32" + "v32", + "v0" ], "op": "sub", "out": [ @@ -973,9 +973,9 @@ Yul Control Flow Graph: }, { "in": [ - "v59", + "0x00", "v0", - "0x00" + "v59" ], "op": "create", "out": [ @@ -1044,8 +1044,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x026121ff", - "0xe4" + "0xe4", + "0x026121ff" ], "op": "shl", "out": [ @@ -1054,16 +1054,16 @@ Yul Control Flow Graph: }, { "in": [ - "v71", - "v68" + "v68", + "v71" ], "op": "mstore", "out": [] }, { "in": [ - "0x01", - "0xa0" + "0xa0", + "0x01" ], "op": "shl", "out": [ @@ -1072,8 +1072,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x01", - "v76" + "v76", + "0x01" ], "op": "sub", "out": [ @@ -1082,8 +1082,8 @@ Yul Control Flow Graph: }, { "in": [ - "v77", - "v60" + "v60", + "v77" ], "op": "and", "out": [ @@ -1099,12 +1099,12 @@ Yul Control Flow Graph: }, { "in": [ - "0x20", + "v83", + "v82", "v68", "0x04", "v68", - "v82", - "v83" + "0x20" ], "op": "staticcall", "out": [ @@ -1220,16 +1220,16 @@ Yul Control Flow Graph: }, { "in": [ - "phi146", - "v145" + "v145", + "phi146" ], "op": "mstore", "out": [] }, { "in": [ - "0x20", - "v145" + "v145", + "0x20" ], "op": "return", "out": [] @@ -1263,8 +1263,8 @@ Yul Control Flow Graph: }, { "in": [ - "v96", - "0x20" + "0x20", + "v96" ], "op": "gt", "out": [ @@ -1318,8 +1318,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x1f", - "phi101" + "phi101", + "0x1f" ], "op": "add", "out": [ @@ -1328,8 +1328,8 @@ Yul Control Flow Graph: }, { "in": [ - "v100", - "v104" + "v104", + "v100" ], "op": "and", "out": [ @@ -1338,8 +1338,8 @@ Yul Control Flow Graph: }, { "in": [ - "v105", - "v68" + "v68", + "v105" ], "op": "add", "out": [ @@ -1348,8 +1348,8 @@ Yul Control Flow Graph: }, { "in": [ - "v68", - "v113" + "v113", + "v68" ], "op": "lt", "out": [ @@ -1358,8 +1358,8 @@ Yul Control Flow Graph: }, { "in": [ - "0xffffffffffffffff", - "v113" + "v113", + "0xffffffffffffffff" ], "op": "gt", "out": [ @@ -1368,8 +1368,8 @@ Yul Control Flow Graph: }, { "in": [ - "v114", - "v115" + "v115", + "v114" ], "op": "or", "out": [ @@ -1431,16 +1431,16 @@ Yul Control Flow Graph: "instructions": [ { "in": [ - "v113", - "0x40" + "0x40", + "v113" ], "op": "mstore", "out": [] }, { "in": [ - "phi101", - "v68" + "v68", + "phi101" ], "op": "add", "out": [ @@ -1449,8 +1449,8 @@ Yul Control Flow Graph: }, { "in": [ - "v68", - "v135" + "v135", + "v68" ], "op": "sub", "out": [ @@ -1459,8 +1459,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x20", - "v136" + "v136", + "0x20" ], "op": "slt", "out": [ @@ -1558,8 +1558,8 @@ Yul Control Flow Graph: "instructions": [ { "in": [ - "0x4e487b71", - "0xe0" + "0xe0", + "0x4e487b71" ], "op": "shl", "out": [ @@ -1568,24 +1568,24 @@ Yul Control Flow Graph: }, { "in": [ - "v2", - "0x00" + "0x00", + "v2" ], "op": "mstore", "out": [] }, { "in": [ - "0x41", - "0x04" + "0x04", + "0x41" ], "op": "mstore", "out": [] }, { "in": [ - "0x24", - "0x00" + "0x00", + "0x24" ], "op": "revert", "out": [] @@ -1629,9 +1629,9 @@ Yul Control Flow Graph: }, { "in": [ - "v2", + "v1", "0x00", - "v1" + "v2" ], "op": "returndatacopy", "out": [] @@ -1645,8 +1645,8 @@ Yul Control Flow Graph: }, { "in": [ - "v5", - "v1" + "v1", + "v5" ], "op": "revert", "out": [] @@ -1717,8 +1717,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -1767,17 +1767,17 @@ Yul Control Flow Graph: }, { "in": [ - "v7", + "v0", "v8", - "v0" + "v7" ], "op": "codecopy", "out": [] }, { "in": [ - "v7", - "v0" + "v0", + "v7" ], "op": "return", "out": [] @@ -1838,8 +1838,8 @@ Yul Control Flow Graph: }, { "in": [ - "v0", - "0x40" + "0x40", + "v0" ], "op": "mstore", "out": [] @@ -1853,8 +1853,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x04", - "v4" + "v4", + "0x04" ], "op": "lt", "out": [ @@ -1919,8 +1919,8 @@ Yul Control Flow Graph: }, { "in": [ - "v8", - "0xe0" + "0xe0", + "v8" ], "op": "shr", "out": [ @@ -1929,8 +1929,8 @@ Yul Control Flow Graph: }, { "in": [ - "v10", - "0x26121ff0" + "0x26121ff0", + "v10" ], "op": "eq", "out": [ @@ -2020,8 +2020,8 @@ Yul Control Flow Graph: }, { "in": [ - "v17", - "v18" + "v18", + "v17" ], "op": "add", "out": [ @@ -2030,8 +2030,8 @@ Yul Control Flow Graph: }, { "in": [ - "0x00", - "v19" + "v19", + "0x00" ], "op": "slt", "out": [ @@ -2075,16 +2075,16 @@ Yul Control Flow Graph: "instructions": [ { "in": [ - "0x2a", - "v0" + "v0", + "0x2a" ], "op": "mstore", "out": [] }, { "in": [ - "0x20", - "v0" + "v0", + "0x20" ], "op": "return", "out": [] diff --git a/test/libyul/ssa/controlFlowGraph/complex.yul b/test/libyul/ssa/controlFlowGraph/complex.yul index c1bc8f16ed8f..12af4e2c9d6d 100644 --- a/test/libyul/ssa/controlFlowGraph/complex.yul +++ b/test/libyul/ssa/controlFlowGraph/complex.yul @@ -53,7 +53,7 @@ // Entry -> Block0_0; // Block0_0 [fillcolor="#FF746C", style=filled, label="\ // Block 0; (0, max 0)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nv2 := f(0x02, 0x01)\l\ +// LiveOut: \l\nUsed: \l\nv2 := f(0x01, 0x02)\l\ // pop(v2)\l\ // "]; // Block0_0Exit [label="MainExit"]; @@ -73,7 +73,7 @@ // Block 0 => 0x2a,\l\ // Block 21 => v63\l\ // )\l\ -// v6 := lt(v0, phi5)\l\ +// v6 := lt(phi5, v0)\l\ // "]; // Block1_1 -> Block1_1Exit; // Block1_1Exit [label="{ If v6 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -82,7 +82,7 @@ // Block1_2 [label="\ // Block 2; (2, max 17)\nLiveIn: phi5[2], v1[1], v0[1]\l\ // LiveOut: phi5[1], v1[1], v7[3], v0[1]\l\nUsed: phi5[1]\l\nv7 := mload(phi5)\l\ -// v8 := eq(0x00, v7)\l\ +// v8 := eq(v7, 0x00)\l\ // "]; // Block1_2 -> Block1_2Exit; // Block1_2Exit [label="{ If v8 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -90,20 +90,20 @@ // Block1_2Exit:1 -> Block1_6 [style="solid"]; // Block1_4 [label="\ // Block 4; (4, max 4)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0c0c, 0x0c)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x0c, 0x0c0c)\l\ // "]; // Block1_4Exit [label="FunctionReturn[0x00]"]; // Block1_4 -> Block1_4Exit; // Block1_6 [label="\ // Block 6; (3, max 4)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0202, 0x02)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x02, 0x0202)\l\ // "]; // Block1_6 -> Block1_6Exit [arrowhead=none]; // Block1_6Exit [label="Jump" shape=oval]; // Block1_6Exit -> Block1_4 [style="solid"]; // Block1_7 [label="\ // Block 7; (5, max 17)\nLiveIn: phi5[1], v1[1], v7[3], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v7[2], v0[1]\l\nUsed: v7[1]\l\nv16 := eq(0x01, v7)\l\ +// LiveOut: phi5[1], v1[1], v7[2], v0[1]\l\nUsed: v7[1]\l\nv16 := eq(v7, 0x01)\l\ // "]; // Block1_7 -> Block1_7Exit; // Block1_7Exit [label="{ If v16 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -111,13 +111,13 @@ // Block1_7Exit:1 -> Block1_9 [style="solid"]; // Block1_9 [label="\ // Block 9; (6, max 6)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0404, 0x04)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x04, 0x0404)\l\ // "]; // Block1_9Exit [label="FunctionReturn[0x00]"]; // Block1_9 -> Block1_9Exit; // Block1_10 [label="\ // Block 10; (7, max 17)\nLiveIn: phi5[1], v1[1], v7[2], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v7[1], v0[1]\l\nUsed: v7[1]\l\nv24 := eq(0x02, v7)\l\ +// LiveOut: phi5[1], v1[1], v7[1], v0[1]\l\nUsed: v7[1]\l\nv24 := eq(v7, 0x02)\l\ // "]; // Block1_10 -> Block1_10Exit; // Block1_10Exit [label="{ If v24 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -125,14 +125,14 @@ // Block1_10Exit:1 -> Block1_12 [style="solid"]; // Block1_12 [fillcolor="#FF746C", style=filled, label="\ // Block 12; (8, max 8)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0606, 0x06)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x06, 0x0606)\l\ // revert(0x00, 0x00)\l\ // "]; // Block1_12Exit [label="Terminated"]; // Block1_12 -> Block1_12Exit; // Block1_13 [label="\ // Block 13; (9, max 17)\nLiveIn: phi5[1], v1[1], v7[1], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: v7[1]\l\nv33 := eq(0x03, v7)\l\ +// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: v7[1]\l\nv33 := eq(v7, 0x03)\l\ // "]; // Block1_13 -> Block1_13Exit; // Block1_13Exit [label="{ If v33 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -140,7 +140,7 @@ // Block1_13Exit:1 -> Block1_15 [style="solid"]; // Block1_15 [label="\ // Block 15; (10, max 14)\nLiveIn: phi5[1], v1[1], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0808, 0x08)\l\ +// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x08, 0x0808)\l\ // "]; // Block1_15 -> Block1_15Exit [arrowhead=none]; // Block1_15Exit [label="Jump" shape=oval]; @@ -155,7 +155,7 @@ // Block1_16Exit:1 -> Block1_17 [style="solid"]; // Block1_5 [label="\ // Block 5; (11, max 14)\nLiveIn: phi5[1], v1[1], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0b0b, 0x0b)\l\ +// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0b, 0x0b0b)\l\ // "]; // Block1_5 -> Block1_5Exit [arrowhead=none]; // Block1_5Exit [label="Jump" shape=oval]; @@ -168,14 +168,14 @@ // Block1_17 -> Block1_17Exit; // Block1_18 [label="\ // Block 18; (17, max 17)\nLiveIn: phi5[1], v1[1], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0a0a, 0x0a)\l\ +// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0a, 0x0a0a)\l\ // "]; // Block1_18 -> Block1_18Exit [arrowhead=none]; // Block1_18Exit [label="Jump" shape=oval]; // Block1_18Exit -> Block1_5 [style="solid"]; // Block1_3 [label="\ // Block 3; (12, max 14)\nLiveIn: phi5[1], v1[1], v0[1]\l\ -// LiveOut: v63[1], v1[1], v0[1]\l\nUsed: phi5[1]\l\nv63 := add(0x01, phi5)\l\ +// LiveOut: v63[1], v1[1], v0[1]\l\nUsed: phi5[1]\l\nv63 := add(phi5, 0x01)\l\ // v64 := calldataload(v63)\l\ // "]; // Block1_3 -> Block1_3Exit; @@ -184,13 +184,13 @@ // Block1_3Exit:1 -> Block1_20 [style="solid"]; // Block1_20 [label="\ // Block 20; (13, max 13)\nLiveIn: v63[1]\l\ -// LiveOut: \l\nUsed: v63[1]\l\nsstore(v63, 0x00)\l\ +// LiveOut: \l\nUsed: v63[1]\l\nsstore(0x00, v63)\l\ // "]; // Block1_20Exit [label="FunctionReturn[0x00]"]; // Block1_20 -> Block1_20Exit; // Block1_21 [label="\ // Block 21; (14, max 14)\nLiveIn: v63[1], v1[1], v0[1]\l\ -// LiveOut: v63[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0xffff, 0xff)\l\ +// LiveOut: v63[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0xff, 0xffff)\l\ // "]; // Block1_21 -> Block1_21Exit [arrowhead=none]; // Block1_21Exit [label="Jump" shape=oval]; diff --git a/test/libyul/ssa/controlFlowGraph/complex2.yul b/test/libyul/ssa/controlFlowGraph/complex2.yul index 6f8f5fbc7773..15caca756ee6 100644 --- a/test/libyul/ssa/controlFlowGraph/complex2.yul +++ b/test/libyul/ssa/controlFlowGraph/complex2.yul @@ -61,16 +61,16 @@ // Block0_0 [fillcolor="#FF746C", style=filled, label="\ // Block 0; (0, max 0)\nLiveIn: \l\ // LiveOut: \l\nUsed: \l\nsstore(0x01, 0x01)\l\ -// v3 := f(0x02, 0x01)\l\ +// v3 := f(0x01, 0x02)\l\ // pop(v3)\l\ // v6 := sload(0x00)\l\ -// v8 := add(v6, 0x05)\l\ +// v8 := add(0x05, v6)\l\ // v10 := sload(0x04)\l\ -// v11 := f(v10, v8)\l\ -// sstore(v11, v8)\l\ +// v11 := f(v8, v10)\l\ +// sstore(v8, v11)\l\ // v13 := sload(0x05)\l\ -// v14 := f(v13, v11)\l\ -// sstore(v14, 0x01)\l\ +// v14 := f(v11, v13)\l\ +// sstore(0x01, v14)\l\ // "]; // Block0_0Exit [label="MainExit"]; // Block0_0 -> Block0_0Exit; @@ -89,7 +89,7 @@ // Block 0 => 0x2a,\l\ // Block 21 => v63\l\ // )\l\ -// v6 := lt(v0, phi5)\l\ +// v6 := lt(phi5, v0)\l\ // "]; // Block1_1 -> Block1_1Exit; // Block1_1Exit [label="{ If v6 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -98,7 +98,7 @@ // Block1_2 [label="\ // Block 2; (2, max 17)\nLiveIn: phi5[2], v1[1], v0[1]\l\ // LiveOut: phi5[1], v1[1], v7[3], v0[1]\l\nUsed: phi5[1]\l\nv7 := mload(phi5)\l\ -// v8 := eq(0x00, v7)\l\ +// v8 := eq(v7, 0x00)\l\ // "]; // Block1_2 -> Block1_2Exit; // Block1_2Exit [label="{ If v8 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -106,20 +106,20 @@ // Block1_2Exit:1 -> Block1_6 [style="solid"]; // Block1_4 [label="\ // Block 4; (4, max 4)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0c0c, 0x0c)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x0c, 0x0c0c)\l\ // "]; // Block1_4Exit [label="FunctionReturn[0x1b]"]; // Block1_4 -> Block1_4Exit; // Block1_6 [label="\ // Block 6; (3, max 4)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0202, 0x02)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x02, 0x0202)\l\ // "]; // Block1_6 -> Block1_6Exit [arrowhead=none]; // Block1_6Exit [label="Jump" shape=oval]; // Block1_6Exit -> Block1_4 [style="solid"]; // Block1_7 [label="\ // Block 7; (5, max 17)\nLiveIn: phi5[1], v1[1], v7[3], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v7[2], v0[1]\l\nUsed: v7[1]\l\nv16 := eq(0x01, v7)\l\ +// LiveOut: phi5[1], v1[1], v7[2], v0[1]\l\nUsed: v7[1]\l\nv16 := eq(v7, 0x01)\l\ // "]; // Block1_7 -> Block1_7Exit; // Block1_7Exit [label="{ If v16 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -127,13 +127,13 @@ // Block1_7Exit:1 -> Block1_9 [style="solid"]; // Block1_9 [label="\ // Block 9; (6, max 6)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0404, 0x04)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x04, 0x0404)\l\ // "]; // Block1_9Exit [label="FunctionReturn[0x00]"]; // Block1_9 -> Block1_9Exit; // Block1_10 [label="\ // Block 10; (7, max 17)\nLiveIn: phi5[1], v1[1], v7[2], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v7[1], v0[1]\l\nUsed: v7[1]\l\nv24 := eq(0x02, v7)\l\ +// LiveOut: phi5[1], v1[1], v7[1], v0[1]\l\nUsed: v7[1]\l\nv24 := eq(v7, 0x02)\l\ // "]; // Block1_10 -> Block1_10Exit; // Block1_10Exit [label="{ If v24 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -141,14 +141,14 @@ // Block1_10Exit:1 -> Block1_12 [style="solid"]; // Block1_12 [fillcolor="#FF746C", style=filled, label="\ // Block 12; (8, max 8)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0606, 0x06)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x06, 0x0606)\l\ // revert(0x00, 0x00)\l\ // "]; // Block1_12Exit [label="Terminated"]; // Block1_12 -> Block1_12Exit; // Block1_13 [label="\ // Block 13; (9, max 17)\nLiveIn: phi5[1], v1[1], v7[1], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: v7[1]\l\nv33 := eq(0x03, v7)\l\ +// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: v7[1]\l\nv33 := eq(v7, 0x03)\l\ // "]; // Block1_13 -> Block1_13Exit; // Block1_13Exit [label="{ If v33 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -156,7 +156,7 @@ // Block1_13Exit:1 -> Block1_15 [style="solid"]; // Block1_15 [label="\ // Block 15; (10, max 14)\nLiveIn: phi5[1], v1[1], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0808, 0x08)\l\ +// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x08, 0x0808)\l\ // "]; // Block1_15 -> Block1_15Exit [arrowhead=none]; // Block1_15Exit [label="Jump" shape=oval]; @@ -171,7 +171,7 @@ // Block1_16Exit:1 -> Block1_17 [style="solid"]; // Block1_5 [label="\ // Block 5; (11, max 14)\nLiveIn: phi5[1], v1[1], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0b0b, 0x0b)\l\ +// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0b, 0x0b0b)\l\ // "]; // Block1_5 -> Block1_5Exit [arrowhead=none]; // Block1_5Exit [label="Jump" shape=oval]; @@ -184,14 +184,14 @@ // Block1_17 -> Block1_17Exit; // Block1_18 [label="\ // Block 18; (17, max 17)\nLiveIn: phi5[1], v1[1], v0[1]\l\ -// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0a0a, 0x0a)\l\ +// LiveOut: phi5[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0x0a, 0x0a0a)\l\ // "]; // Block1_18 -> Block1_18Exit [arrowhead=none]; // Block1_18Exit [label="Jump" shape=oval]; // Block1_18Exit -> Block1_5 [style="solid"]; // Block1_3 [label="\ // Block 3; (12, max 14)\nLiveIn: phi5[1], v1[1], v0[1]\l\ -// LiveOut: v63[1], v1[1], v0[1]\l\nUsed: phi5[1]\l\nv63 := add(0x01, phi5)\l\ +// LiveOut: v63[1], v1[1], v0[1]\l\nUsed: phi5[1]\l\nv63 := add(phi5, 0x01)\l\ // v64 := calldataload(v63)\l\ // "]; // Block1_3 -> Block1_3Exit; @@ -200,13 +200,13 @@ // Block1_3Exit:1 -> Block1_20 [style="solid"]; // Block1_20 [label="\ // Block 20; (13, max 13)\nLiveIn: v63[1]\l\ -// LiveOut: \l\nUsed: v63[1]\l\nsstore(v63, 0x00)\l\ +// LiveOut: \l\nUsed: v63[1]\l\nsstore(0x00, v63)\l\ // "]; // Block1_20Exit [label="FunctionReturn[0x00]"]; // Block1_20 -> Block1_20Exit; // Block1_21 [label="\ // Block 21; (14, max 14)\nLiveIn: v63[1], v1[1], v0[1]\l\ -// LiveOut: v63[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0xffff, 0xff)\l\ +// LiveOut: v63[1], v1[1], v0[1]\l\nUsed: \l\nsstore(0xff, 0xffff)\l\ // "]; // Block1_21 -> Block1_21Exit [arrowhead=none]; // Block1_21Exit [label="Jump" shape=oval]; diff --git a/test/libyul/ssa/controlFlowGraph/function.yul b/test/libyul/ssa/controlFlowGraph/function.yul index b91d9f652a4a..220eb4f25311 100644 --- a/test/libyul/ssa/controlFlowGraph/function.yul +++ b/test/libyul/ssa/controlFlowGraph/function.yul @@ -40,8 +40,8 @@ // FunctionEntry_f_0 -> Block1_0; // Block1_0 [label="\ // Block 0; (0, max 0)\nLiveIn: v0[2], v1[1]\l\ -// LiveOut: v4[1]\l\nUsed: v0[2], v1[1]\l\nv3 := add(v1, v0)\l\ -// v4 := sub(v0, v3)\l\ +// LiveOut: v4[1]\l\nUsed: v0[2], v1[1]\l\nv3 := add(v0, v1)\l\ +// v4 := sub(v3, v0)\l\ // "]; // Block1_0Exit [label="FunctionReturn[v4]"]; // Block1_0 -> Block1_0Exit; @@ -50,7 +50,7 @@ // FunctionEntry_g_0 -> Block2_0; // Block2_0 [label="\ // Block 0; (0, max 0)\nLiveIn: \l\ -// LiveOut: \l\nUsed: \l\nsstore(0x0101, 0x01)\l\ +// LiveOut: \l\nUsed: \l\nsstore(0x01, 0x0101)\l\ // "]; // Block2_0Exit [label="FunctionReturn[]"]; // Block2_0 -> Block2_0Exit; @@ -59,7 +59,7 @@ // FunctionEntry_h_0 -> Block3_0; // Block3_0 [fillcolor="#FF746C", style=filled, label="\ // Block 0; (0, max 0)\nLiveIn: v0[1]\l\ -// LiveOut: \l\nUsed: v0[1]\l\nv2 := f(0x00, v0)\l\ +// LiveOut: \l\nUsed: v0[1]\l\nv2 := f(v0, 0x00)\l\ // h(v2)\l\ // "]; // Block3_0Exit [label="Terminated"]; diff --git a/test/libyul/ssa/controlFlowGraph/if.yul b/test/libyul/ssa/controlFlowGraph/if.yul index 038c196da9c5..b05881f09162 100644 --- a/test/libyul/ssa/controlFlowGraph/if.yul +++ b/test/libyul/ssa/controlFlowGraph/if.yul @@ -37,7 +37,7 @@ // Block 1 => v5\l\ // )\l\ // v9 := calldataload(phi6)\l\ -// sstore(0x00, v9)\l\ +// sstore(v9, 0x00)\l\ // "]; // Block0_2Exit [label="MainExit"]; // Block0_2 -> Block0_2Exit; diff --git a/test/libyul/ssa/controlFlowGraph/if_const.yul b/test/libyul/ssa/controlFlowGraph/if_const.yul index 48b240a179fd..a54938ae0812 100644 --- a/test/libyul/ssa/controlFlowGraph/if_const.yul +++ b/test/libyul/ssa/controlFlowGraph/if_const.yul @@ -24,7 +24,7 @@ // LiveOut: \l\nUsed: \l\nv1 := calldataload(0x03)\l\ // v3 := calldataload(0x2a)\l\ // v4 := calldataload(v3)\l\ -// sstore(0x00, v4)\l\ +// sstore(v4, 0x00)\l\ // "]; // Block0_0Exit [label="MainExit"]; // Block0_0 -> Block0_0Exit; diff --git a/test/libyul/ssa/controlFlowGraph/memoryguard.yul b/test/libyul/ssa/controlFlowGraph/memoryguard.yul index e7dac6076821..43ab5b46048d 100644 --- a/test/libyul/ssa/controlFlowGraph/memoryguard.yul +++ b/test/libyul/ssa/controlFlowGraph/memoryguard.yul @@ -15,9 +15,9 @@ // Block0_0 [fillcolor="#FF746C", style=filled, label="\ // Block 0; (0, max 0)\nLiveIn: \l\ // LiveOut: \l\nUsed: \l\nv0 := memoryguard<0x80>()\l\ -// mstore(0x2a, v0)\l\ +// mstore(v0, 0x2a)\l\ // v3 := memoryguard<0x80>()\l\ -// sstore(0x01, v3)\l\ +// sstore(v3, 0x01)\l\ // "]; // Block0_0Exit [label="MainExit"]; // Block0_0 -> Block0_0Exit; diff --git a/test/libyul/ssa/controlFlowGraph/nested_for.yul b/test/libyul/ssa/controlFlowGraph/nested_for.yul index e3c1ef7e6021..34cebf6d7062 100644 --- a/test/libyul/ssa/controlFlowGraph/nested_for.yul +++ b/test/libyul/ssa/controlFlowGraph/nested_for.yul @@ -37,7 +37,7 @@ // Block 0 => 0x00,\l\ // Block 3 => v78\l\ // )\l\ -// v3 := lt(0x03, phi2)\l\ +// v3 := lt(phi2, 0x03)\l\ // "]; // Block0_1 -> Block0_1Exit; // Block0_1Exit [label="{ If v3 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -55,20 +55,20 @@ // Block0_4Exit [label="MainExit"]; // Block0_4 -> Block0_4Exit; // Block0_5 [label="\ -// Block 5; (3, max 23)\nLiveIn: phi4[3], phi2[1]\l\ -// LiveOut: phi4[1], phi2[1]\l\nUsed: phi4[2]\l\nphi4 := φ(\l\ +// Block 5; (3, max 23)\nLiveIn: phi2[1], phi4[3]\l\ +// LiveOut: phi2[1], phi4[1]\l\nUsed: phi4[2]\l\nphi4 := φ(\l\ // Block 2 => 0x00,\l\ // Block 7 => v73\l\ // )\l\ -// v5 := lt(0x03, phi4)\l\ +// v5 := lt(phi4, 0x03)\l\ // "]; // Block0_5 -> Block0_5Exit; // Block0_5Exit [label="{ If v5 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; // Block0_5Exit:0 -> Block0_8 [style="solid"]; // Block0_5Exit:1 -> Block0_6 [style="solid"]; // Block0_6 [label="\ -// Block 6; (4, max 21)\nLiveIn: phi4[1], phi2[1]\l\ -// LiveOut: phi4[1], phi2[1]\l\nUsed: \l\n"]; +// Block 6; (4, max 21)\nLiveIn: phi2[1], phi4[1]\l\ +// LiveOut: phi2[1], phi4[1]\l\nUsed: \l\n"]; // Block0_6 -> Block0_6Exit [arrowhead=none]; // Block0_6Exit [label="Jump" shape=oval]; // Block0_6Exit -> Block0_9 [style="solid"]; @@ -79,12 +79,12 @@ // Block0_8Exit [label="Jump" shape=oval]; // Block0_8Exit -> Block0_3 [style="solid"]; // Block0_9 [label="\ -// Block 9; (5, max 21)\nLiveIn: phi6[3], phi4[1], phi2[1]\l\ -// LiveOut: phi6[1], phi4[1], phi2[1]\l\nUsed: phi6[2]\l\nphi6 := φ(\l\ +// Block 9; (5, max 21)\nLiveIn: phi6[3], phi2[1], phi4[1]\l\ +// LiveOut: phi6[1], phi2[1], phi4[1]\l\nUsed: phi6[2]\l\nphi6 := φ(\l\ // Block 6 => 0x00,\l\ // Block 11 => v59\l\ // )\l\ -// v7 := lt(0x03, phi6)\l\ +// v7 := lt(phi6, 0x03)\l\ // "]; // Block0_9 -> Block0_9Exit; // Block0_9Exit [label="{ If v7 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -92,14 +92,14 @@ // Block0_9Exit:1 -> Block0_10 [style="solid"]; // Block0_3 [label="\ // Block 3; (23, max 23)\nLiveIn: phi2[1]\l\ -// LiveOut: v78[1]\l\nUsed: phi2[1]\l\nv78 := add(0x01, phi2)\l\ +// LiveOut: v78[1]\l\nUsed: phi2[1]\l\nv78 := add(phi2, 0x01)\l\ // "]; // Block0_3 -> Block0_3Exit [arrowhead=none]; // Block0_3Exit [label="Jump" shape=oval]; // Block0_3Exit -> Block0_1 [style="dashed"]; // Block0_10 [label="\ -// Block 10; (6, max 19)\nLiveIn: phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi6[1], phi4[1], phi2[1]\l\nUsed: \l\nv8 := mload(0x00)\l\ +// Block 10; (6, max 19)\nLiveIn: phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi6[1], phi2[1], phi4[1]\l\nUsed: \l\nv8 := mload(0x00)\l\ // "]; // Block0_10 -> Block0_10Exit; // Block0_10Exit [label="{ If v8 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -112,14 +112,14 @@ // Block0_12Exit [label="Jump" shape=oval]; // Block0_12Exit -> Block0_7 [style="solid"]; // Block0_13 [label="\ -// Block 13; (7, max 19)\nLiveIn: phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi6[1], phi4[1], phi2[1]\l\nUsed: \l\n"]; +// Block 13; (7, max 19)\nLiveIn: phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi6[1], phi2[1], phi4[1]\l\nUsed: \l\n"]; // Block0_13 -> Block0_13Exit [arrowhead=none]; // Block0_13Exit [label="Jump" shape=oval]; // Block0_13Exit -> Block0_15 [style="solid"]; // Block0_14 [label="\ -// Block 14; (12, max 19)\nLiveIn: phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi6[1], phi4[1], phi2[1]\l\nUsed: \l\nv29 := mload(0x01)\l\ +// Block 14; (12, max 19)\nLiveIn: phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi6[1], phi2[1], phi4[1]\l\nUsed: \l\nv29 := mload(0x01)\l\ // "]; // Block0_14 -> Block0_14Exit; // Block0_14Exit [label="{ If v29 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -127,94 +127,94 @@ // Block0_14Exit:1 -> Block0_19 [style="solid"]; // Block0_7 [label="\ // Block 7; (21, max 21)\nLiveIn: phi4[1], phi2[1]\l\ -// LiveOut: v73[1], phi2[1]\l\nUsed: phi4[1]\l\nv73 := add(0x01, phi4)\l\ +// LiveOut: v73[1], phi2[1]\l\nUsed: phi4[1]\l\nv73 := add(phi4, 0x01)\l\ // "]; // Block0_7 -> Block0_7Exit [arrowhead=none]; // Block0_7Exit [label="Jump" shape=oval]; // Block0_7Exit -> Block0_5 [style="dashed"]; // Block0_15 [label="\ -// Block 15; (8, max 19)\nLiveIn: phi9[4], phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi9[2], phi6[1], phi4[1], phi2[1]\l\nUsed: phi9[2]\l\nphi9 := φ(\l\ +// Block 15; (8, max 19)\nLiveIn: phi9[4], phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi9[2], phi6[1], phi2[1], phi4[1]\l\nUsed: phi9[2]\l\nphi9 := φ(\l\ // Block 13 => 0x00,\l\ // Block 17 => v18\l\ // )\l\ -// v10 := lt(0x03, phi9)\l\ +// v10 := lt(phi9, 0x03)\l\ // "]; // Block0_15 -> Block0_15Exit; // Block0_15Exit [label="{ If v10 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; // Block0_15Exit:0 -> Block0_18 [style="solid"]; // Block0_15Exit:1 -> Block0_16 [style="solid"]; // Block0_19 [label="\ -// Block 19; (13, max 19)\nLiveIn: phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi6[1], phi4[1], phi2[1]\l\nUsed: \l\n"]; +// Block 19; (13, max 19)\nLiveIn: phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi6[1], phi2[1], phi4[1]\l\nUsed: \l\n"]; // Block0_19 -> Block0_19Exit [arrowhead=none]; // Block0_19Exit [label="Jump" shape=oval]; // Block0_19Exit -> Block0_21 [style="solid"]; // Block0_20 [label="\ -// Block 20; (18, max 19)\nLiveIn: phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi6[1], phi4[1], phi2[1]\l\nUsed: \l\n"]; +// Block 20; (18, max 19)\nLiveIn: phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi6[1], phi2[1], phi4[1]\l\nUsed: \l\n"]; // Block0_20 -> Block0_20Exit [arrowhead=none]; // Block0_20Exit [label="Jump" shape=oval]; // Block0_20Exit -> Block0_11 [style="solid"]; // Block0_16 [label="\ -// Block 16; (9, max 10)\nLiveIn: phi9[2], phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi9[1], phi6[1], phi4[1], phi2[1]\l\nUsed: phi9[1]\l\nv14 := add(phi4, phi2)\l\ -// v15 := add(phi6, v14)\l\ -// sstore(v15, phi9)\l\ +// Block 16; (9, max 10)\nLiveIn: phi9[2], phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi9[1], phi6[1], phi2[1], phi4[1]\l\nUsed: phi9[1]\l\nv14 := add(phi2, phi4)\l\ +// v15 := add(v14, phi6)\l\ +// sstore(phi9, v15)\l\ // "]; // Block0_16 -> Block0_16Exit [arrowhead=none]; // Block0_16Exit [label="Jump" shape=oval]; // Block0_16Exit -> Block0_17 [style="solid"]; // Block0_18 [label="\ -// Block 18; (11, max 19)\nLiveIn: phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi6[1], phi4[1], phi2[1]\l\nUsed: \l\n"]; +// Block 18; (11, max 19)\nLiveIn: phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi6[1], phi2[1], phi4[1]\l\nUsed: \l\n"]; // Block0_18 -> Block0_18Exit [arrowhead=none]; // Block0_18Exit [label="Jump" shape=oval]; // Block0_18Exit -> Block0_14 [style="solid"]; // Block0_21 [label="\ -// Block 21; (14, max 19)\nLiveIn: phi30[4], phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi30[2], phi6[1], phi4[1], phi2[1]\l\nUsed: phi30[2]\l\nphi30 := φ(\l\ +// Block 21; (14, max 19)\nLiveIn: phi30[4], phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi30[2], phi6[1], phi2[1], phi4[1]\l\nUsed: phi30[2]\l\nphi30 := φ(\l\ // Block 19 => 0x00,\l\ // Block 23 => v38\l\ // )\l\ -// v31 := lt(0x03, phi30)\l\ +// v31 := lt(phi30, 0x03)\l\ // "]; // Block0_21 -> Block0_21Exit; // Block0_21Exit [label="{ If v31 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; // Block0_21Exit:0 -> Block0_24 [style="solid"]; // Block0_21Exit:1 -> Block0_22 [style="solid"]; // Block0_11 [label="\ -// Block 11; (19, max 19)\nLiveIn: phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: v59[1], phi4[1], phi2[1]\l\nUsed: phi6[1]\l\nv59 := add(0x01, phi6)\l\ +// Block 11; (19, max 19)\nLiveIn: phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: v59[1], phi2[1], phi4[1]\l\nUsed: phi6[1]\l\nv59 := add(phi6, 0x01)\l\ // "]; // Block0_11 -> Block0_11Exit [arrowhead=none]; // Block0_11Exit [label="Jump" shape=oval]; // Block0_11Exit -> Block0_9 [style="dashed"]; // Block0_17 [label="\ -// Block 17; (10, max 10)\nLiveIn: phi9[1], phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: v18[1], phi6[1], phi4[1], phi2[1]\l\nUsed: phi9[1]\l\nv18 := add(0x01, phi9)\l\ +// Block 17; (10, max 10)\nLiveIn: phi9[1], phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: v18[1], phi6[1], phi2[1], phi4[1]\l\nUsed: phi9[1]\l\nv18 := add(phi9, 0x01)\l\ // "]; // Block0_17 -> Block0_17Exit [arrowhead=none]; // Block0_17Exit [label="Jump" shape=oval]; // Block0_17Exit -> Block0_15 [style="dashed"]; // Block0_22 [label="\ -// Block 22; (15, max 16)\nLiveIn: phi30[2], phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi30[1], phi6[1], phi4[1], phi2[1]\l\nUsed: phi30[1]\l\nv35 := add(phi4, phi2)\l\ -// v36 := add(phi6, v35)\l\ -// sstore(v36, phi30)\l\ +// Block 22; (15, max 16)\nLiveIn: phi30[2], phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi30[1], phi6[1], phi2[1], phi4[1]\l\nUsed: phi30[1]\l\nv35 := add(phi2, phi4)\l\ +// v36 := add(v35, phi6)\l\ +// sstore(phi30, v36)\l\ // "]; // Block0_22 -> Block0_22Exit [arrowhead=none]; // Block0_22Exit [label="Jump" shape=oval]; // Block0_22Exit -> Block0_23 [style="solid"]; // Block0_24 [label="\ -// Block 24; (17, max 19)\nLiveIn: phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: phi6[1], phi4[1], phi2[1]\l\nUsed: \l\n"]; +// Block 24; (17, max 19)\nLiveIn: phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: phi6[1], phi2[1], phi4[1]\l\nUsed: \l\n"]; // Block0_24 -> Block0_24Exit [arrowhead=none]; // Block0_24Exit [label="Jump" shape=oval]; // Block0_24Exit -> Block0_20 [style="solid"]; // Block0_23 [label="\ -// Block 23; (16, max 16)\nLiveIn: phi30[1], phi6[1], phi4[1], phi2[1]\l\ -// LiveOut: v38[1], phi6[1], phi4[1], phi2[1]\l\nUsed: phi30[1]\l\nv38 := add(0x01, phi30)\l\ +// Block 23; (16, max 16)\nLiveIn: phi30[1], phi6[1], phi2[1], phi4[1]\l\ +// LiveOut: v38[1], phi6[1], phi2[1], phi4[1]\l\nUsed: phi30[1]\l\nv38 := add(phi30, 0x01)\l\ // "]; // Block0_23 -> Block0_23Exit [arrowhead=none]; // Block0_23Exit [label="Jump" shape=oval]; diff --git a/test/libyul/ssa/controlFlowGraph/nested_function.yul b/test/libyul/ssa/controlFlowGraph/nested_function.yul index 6073978159f0..ad002247559a 100644 --- a/test/libyul/ssa/controlFlowGraph/nested_function.yul +++ b/test/libyul/ssa/controlFlowGraph/nested_function.yul @@ -47,8 +47,8 @@ // FunctionEntry_f_0 -> Block1_0; // Block1_0 [label="\ // Block 0; (0, max 0)\nLiveIn: v0[2], v1[1]\l\ -// LiveOut: v4[1]\l\nUsed: v0[2], v1[1]\l\nv3 := add(v1, v0)\l\ -// v4 := sub(v0, v3)\l\ +// LiveOut: v4[1]\l\nUsed: v0[2], v1[1]\l\nv3 := add(v0, v1)\l\ +// v4 := sub(v3, v0)\l\ // "]; // Block1_0Exit [label="FunctionReturn[v4]"]; // Block1_0 -> Block1_0Exit; @@ -58,9 +58,9 @@ // Block2_0 [label="\ // Block 0; (0, max 0)\nLiveIn: \l\ // LiveOut: \l\nUsed: \l\nv1 := v()\l\ -// v2 := f(0x02, v1)\l\ +// v2 := f(v1, 0x02)\l\ // v3 := z()\l\ -// sstore(v2, v3)\l\ +// sstore(v3, v2)\l\ // "]; // Block2_0Exit [label="FunctionReturn[]"]; // Block2_0 -> Block2_0Exit; diff --git a/test/libyul/ssa/controlFlowGraph/switch.yul b/test/libyul/ssa/controlFlowGraph/switch.yul index 2aa31f0e38d3..597c5bb105d7 100644 --- a/test/libyul/ssa/controlFlowGraph/switch.yul +++ b/test/libyul/ssa/controlFlowGraph/switch.yul @@ -25,7 +25,7 @@ // Block 0; (0, max 5)\nLiveIn: \l\ // LiveOut: v3[1]\l\nUsed: \l\nv1 := calldataload(0x03)\l\ // v3 := sload(0x00)\l\ -// v4 := eq(0x00, v3)\l\ +// v4 := eq(v3, 0x00)\l\ // "]; // Block0_0 -> Block0_0Exit; // Block0_0Exit [label="{ If v4 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -40,7 +40,7 @@ // Block0_2Exit -> Block0_1 [style="solid"]; // Block0_3 [label="\ // Block 3; (3, max 5)\nLiveIn: v3[1]\l\ -// LiveOut: \l\nUsed: v3[1]\l\nv8 := eq(0x01, v3)\l\ +// LiveOut: \l\nUsed: v3[1]\l\nv8 := eq(v3, 0x01)\l\ // "]; // Block0_3 -> Block0_3Exit; // Block0_3Exit [label="{ If v8 | { <0> Zero | <1> NonZero }}" shape=Mrecord]; @@ -53,7 +53,7 @@ // Block 4 => v10,\l\ // Block 5 => v12\l\ // )\l\ -// sstore(0x00, phi13)\l\ +// sstore(phi13, 0x00)\l\ // "]; // Block0_1Exit [label="MainExit"]; // Block0_1 -> Block0_1Exit; diff --git a/test/libyul/ssa/controlFlowGraph/switch_const.yul b/test/libyul/ssa/controlFlowGraph/switch_const.yul index 1dd9dca9bf03..8c15c15c5973 100644 --- a/test/libyul/ssa/controlFlowGraph/switch_const.yul +++ b/test/libyul/ssa/controlFlowGraph/switch_const.yul @@ -48,7 +48,7 @@ // LiveOut: \l\nUsed: \l\nv1 := calldataload(0x03)\l\ // v4 := calldataload(0x58)\l\ // v7 := calldataload(0x63)\l\ -// sstore(0x00, v7)\l\ +// sstore(v7, 0x00)\l\ // "]; // Block0_0Exit [label="MainExit"]; // Block0_0 -> Block0_0Exit;