Skip to content

Commit

Permalink
Yul SSACFG JSON export fix: Function arguments are referenced by thei…
Browse files Browse the repository at this point in the history
…r value ids
  • Loading branch information
clonker committed Oct 31, 2024
1 parent 654ce6b commit 4bbcf05
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 93 deletions.
5 changes: 2 additions & 3 deletions libyul/YulControlFlowGraphExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ Json YulControlFlowGraphExporter::exportFunction(SSACFG const& _cfg)
Json functionJson = Json::object();
functionJson["type"] = "Function";
functionJson["entry"] = "Block" + std::to_string(_cfg.entry.value);
functionJson["arguments"] = Json::array();
for (auto const& [arg, valueId]: _cfg.arguments)
functionJson["arguments"].emplace_back(arg.get().name.str());
static auto constexpr argsTransform = [](auto const& arg) { return fmt::format("v{}", std::get<1>(arg).value); };
functionJson["arguments"] = _cfg.arguments | ranges::views::transform(argsTransform) | ranges::to<std::vector>;
functionJson["returns"] = Json::array();
for (auto const& ret: _cfg.returns)
functionJson["returns"].emplace_back(ret.get().name.str());
Expand Down
90 changes: 45 additions & 45 deletions test/cmdlineTests/standard_yul_cfg_json_export/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@
"functions": {
"abi_decode_tuple_": {
"arguments": [
"headStart",
"dataEnd"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -447,8 +447,8 @@
},
"abi_encode_t_uint256_to_t_uint256_fromStack": {
"arguments": [
"value",
"pos"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -485,8 +485,8 @@
},
"abi_encode_tuple_t_uint256__to_t_uint256__fromStack": {
"arguments": [
"headStart",
"value0"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -569,7 +569,7 @@
},
"cleanup_t_rational_42_by_1": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand All @@ -591,7 +591,7 @@
},
"cleanup_t_uint256": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand All @@ -613,7 +613,7 @@
},
"convert_t_rational_42_by_1_to_t_uint256": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -811,7 +811,7 @@
},
"identity": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -908,7 +908,7 @@
},
"shift_right_224_unsigned": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -1324,8 +1324,8 @@
"functions": {
"abi_decode_t_uint256_fromMemory": {
"arguments": [
"offset",
"end"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -1365,8 +1365,8 @@
},
"abi_decode_tuple_": {
"arguments": [
"headStart",
"dataEnd"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -1432,8 +1432,8 @@
},
"abi_decode_tuple_t_uint256_fromMemory": {
"arguments": [
"headStart",
"dataEnd"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -1525,8 +1525,8 @@
},
"abi_encode_t_uint256_to_t_uint256_fromStack": {
"arguments": [
"value",
"pos"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -1563,7 +1563,7 @@
},
"abi_encode_tuple__to__fromStack": {
"arguments": [
"headStart"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -1597,8 +1597,8 @@
},
"abi_encode_tuple_t_uint256__to_t_uint256__fromStack": {
"arguments": [
"headStart",
"value0"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -1681,7 +1681,7 @@
},
"cleanup_t_uint160": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -1715,7 +1715,7 @@
},
"cleanup_t_uint256": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand All @@ -1737,7 +1737,7 @@
},
"convert_t_contract$_C_$19_to_t_address": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -1770,7 +1770,7 @@
},
"convert_t_uint160_to_t_address": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -1803,7 +1803,7 @@
},
"convert_t_uint160_to_t_uint160": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -1963,8 +1963,8 @@
},
"finalize_allocation": {
"arguments": [
"memPtr",
"size"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -2528,7 +2528,7 @@
},
"identity": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -2771,7 +2771,7 @@
},
"round_up_to_mul_of_32": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -2824,7 +2824,7 @@
},
"shift_left_224": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -2858,7 +2858,7 @@
},
"shift_right_224_unsigned": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -2892,7 +2892,7 @@
},
"validator_revert_t_uint256": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -3367,8 +3367,8 @@
"functions": {
"abi_decode_tuple_": {
"arguments": [
"headStart",
"dataEnd"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -3434,8 +3434,8 @@
},
"abi_encode_t_uint256_to_t_uint256_fromStack": {
"arguments": [
"value",
"pos"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -3472,8 +3472,8 @@
},
"abi_encode_tuple_t_uint256__to_t_uint256__fromStack": {
"arguments": [
"headStart",
"value0"
"v0",
"v1"
],
"blocks": [
{
Expand Down Expand Up @@ -3556,7 +3556,7 @@
},
"cleanup_t_rational_42_by_1": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand All @@ -3578,7 +3578,7 @@
},
"cleanup_t_uint256": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand All @@ -3600,7 +3600,7 @@
},
"convert_t_rational_42_by_1_to_t_uint256": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -3798,7 +3798,7 @@
},
"identity": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down Expand Up @@ -3895,7 +3895,7 @@
},
"shift_right_224_unsigned": {
"arguments": [
"value"
"v0"
],
"blocks": [
{
Expand Down
Loading

0 comments on commit 4bbcf05

Please sign in to comment.