Do not use named function labels if function names are not unique.

This commit is contained in:
chriseth
2021-10-19 18:33:00 +02:00
parent 863a0d3b9c
commit 9f48b7419c
18 changed files with 429 additions and 7 deletions
@@ -0,0 +1 @@
--experimental-via-ir --combined-json function-debug-runtime --pretty-json --json-indent 4
@@ -0,0 +1,5 @@
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> inline_assembly_function_name_clash/input.sol
Warning: Source file does not specify required compiler version!
--> inline_assembly_function_name_clash/input.sol
@@ -0,0 +1,18 @@
contract C {
uint x;
modifier m() {
uint t;
assembly {
function f() -> x { x := 8 }
t := f()
}
x = t;
_;
}
function f() m m public returns (uint r) {
assembly { function f() -> x { x := 1 } r := f() }
}
function g() m m public returns (uint r) {
assembly { function f() -> x { x := 2 } r := f() }
}
}
@@ -0,0 +1,168 @@
{
"contracts":
{
"inline_assembly_function_name_clash/input.sol:C":
{
"function-debug-runtime":
{
"abi_decode_tuple_":
{
"entryPoint": 216,
"parameterSlots": 2,
"returnSlots": 0
},
"abi_encode_t_uint256_to_t_uint256_fromStack":
{
"entryPoint": 250,
"parameterSlots": 2,
"returnSlots": 0
},
"abi_encode_tuple_t_uint256__to_t_uint256__fromStack":
{
"entryPoint": 265,
"parameterSlots": 2,
"returnSlots": 1
},
"allocate_unbounded":
{
"entryPoint": 196,
"parameterSlots": 0,
"returnSlots": 1
},
"cleanup_t_uint256":
{
"entryPoint": 240,
"parameterSlots": 1,
"returnSlots": 1
},
"convert_t_uint256_to_t_uint256":
{
"entryPoint": 391,
"parameterSlots": 1,
"returnSlots": 1
},
"fun_f_25":
{
"entryPoint": 658,
"id": 25,
"parameterSlots": 0,
"returnSlots": 1
},
"fun_f_25_inner":
{
"entryPoint": 624,
"parameterSlots": 1,
"returnSlots": 1
},
"fun_g_36":
{
"entryPoint": 874,
"id": 36,
"parameterSlots": 0,
"returnSlots": 1
},
"fun_g_36_inner":
{
"entryPoint": 840,
"parameterSlots": 1,
"returnSlots": 1
},
"identity":
{
"entryPoint": 381,
"parameterSlots": 1,
"returnSlots": 1
},
"modifier_m_17":
{
"entryPoint": 470,
"id": 14,
"parameterSlots": 1,
"returnSlots": 1
},
"modifier_m_19":
{
"entryPoint": 547,
"id": 14,
"parameterSlots": 1,
"returnSlots": 1
},
"modifier_m_28":
{
"entryPoint": 686,
"id": 14,
"parameterSlots": 1,
"returnSlots": 1
},
"modifier_m_30":
{
"entryPoint": 763,
"id": 14,
"parameterSlots": 1,
"returnSlots": 1
},
"prepare_store_t_uint256":
{
"entryPoint": 425,
"parameterSlots": 1,
"returnSlots": 1
},
"revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74":
{
"entryPoint": 292,
"parameterSlots": 0,
"returnSlots": 0
},
"revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb":
{
"entryPoint": 206,
"parameterSlots": 0,
"returnSlots": 0
},
"revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b":
{
"entryPoint": 211,
"parameterSlots": 0,
"returnSlots": 0
},
"shift_left_0":
{
"entryPoint": 302,
"parameterSlots": 1,
"returnSlots": 1
},
"shift_right_224_unsigned":
{
"entryPoint": 183,
"parameterSlots": 1,
"returnSlots": 1
},
"update_byte_slice_32_shift_0":
{
"entryPoint": 315,
"parameterSlots": 2,
"returnSlots": 1
},
"update_storage_value_offset_0t_uint256_to_t_uint256":
{
"entryPoint": 435,
"parameterSlots": 2,
"returnSlots": 0
},
"usr$f":
{
"entryPoint": 493,
"parameterSlots": 0,
"returnSlots": 1
},
"zero_value_for_split_t_uint256":
{
"entryPoint": 297,
"parameterSlots": 0,
"returnSlots": 1
}
}
}
},
"version": "<VERSION REMOVED>"
}
@@ -0,0 +1 @@
--strict-assembly --debug-info none
@@ -0,0 +1 @@
Warning: Yul is still experimental. Please use the output with care.
@@ -0,0 +1,17 @@
object "object" {
code {
let a
let b
{
function z() -> y
{ y := calldataload(0) }
a := z()
}
{
function z() -> y
{ y := calldataload(0x20) }
b := z()
}
sstore(a, b)
}
}
@@ -0,0 +1,66 @@
======= yul_function_name_clashes/input.yul (EVM) =======
Pretty printed source:
object "object" {
code {
let a
let b
{
function z() -> y
{ y := calldataload(0) }
a := z()
}
{
function z() -> y
{ y := calldataload(0x20) }
b := z()
}
sstore(a, b)
}
}
Binary representation:
600080600f565b60008035905090565b60156006565b91506025565b6000602035905090565b602b601b565b90508082555050
Text representation:
0x00
dup1
jump(tag_2)
tag_1:
0x00
dup1
calldataload
swap1
pop
swap1
jump // out
tag_2:
tag_4
tag_1
jump // in
tag_4:
swap2
pop
jump(tag_6)
tag_5:
0x00
0x20
calldataload
swap1
pop
swap1
jump // out
tag_6:
tag_8
tag_5
jump // in
tag_8:
swap1
pop
dup1
dup3
sstore
pop
pop
@@ -0,0 +1 @@
--strict-assembly
@@ -0,0 +1 @@
Warning: Yul is still experimental. Please use the output with care.
@@ -0,0 +1,17 @@
object "object" {
code {
let a
let b
{
function z() -> y
{ y := calldataload(0) }
a := z()
}
{
function z(r) -> y
{ y := calldataload(r) }
b := z(0x70)
}
sstore(a, b)
}
}
@@ -0,0 +1,93 @@
======= yul_function_name_clashes_different_params/input.yul (EVM) =======
Pretty printed source:
object "object" {
code {
let a
let b
{
function z() -> y
{ y := calldataload(0) }
a := z()
}
{
function z(r) -> y
{ y := calldataload(r) }
b := z(0x70)
}
sstore(a, b)
}
}
Binary representation:
600080600f565b60008035905090565b60156006565b91506026565b600081359050919050565b602e6070601b565b90508082555050
Text representation:
/* "yul_function_name_clashes_different_params/input.yul":37:42 */
0x00
/* "yul_function_name_clashes_different_params/input.yul":51:56 */
dup1
/* "yul_function_name_clashes_different_params/input.yul":79:133 */
jump(tag_2)
tag_1:
/* "yul_function_name_clashes_different_params/input.yul":95:96 */
0x00
/* "yul_function_name_clashes_different_params/input.yul":129:130 */
dup1
/* "yul_function_name_clashes_different_params/input.yul":116:131 */
calldataload
/* "yul_function_name_clashes_different_params/input.yul":111:131 */
swap1
pop
/* "yul_function_name_clashes_different_params/input.yul":79:133 */
swap1
jump // out
tag_2:
/* "yul_function_name_clashes_different_params/input.yul":151:154 */
tag_4
tag_1
jump // in
tag_4:
/* "yul_function_name_clashes_different_params/input.yul":146:154 */
swap2
pop
/* "yul_function_name_clashes_different_params/input.yul":187:242 */
jump(tag_6)
tag_5:
/* "yul_function_name_clashes_different_params/input.yul":204:205 */
0x00
/* "yul_function_name_clashes_different_params/input.yul":238:239 */
dup2
/* "yul_function_name_clashes_different_params/input.yul":225:240 */
calldataload
/* "yul_function_name_clashes_different_params/input.yul":220:240 */
swap1
pop
/* "yul_function_name_clashes_different_params/input.yul":187:242 */
swap2
swap1
pop
jump // out
tag_6:
/* "yul_function_name_clashes_different_params/input.yul":260:267 */
tag_8
/* "yul_function_name_clashes_different_params/input.yul":262:266 */
0x70
/* "yul_function_name_clashes_different_params/input.yul":260:267 */
tag_5
jump // in
tag_8:
/* "yul_function_name_clashes_different_params/input.yul":255:267 */
swap1
pop
/* "yul_function_name_clashes_different_params/input.yul":296:297 */
dup1
/* "yul_function_name_clashes_different_params/input.yul":293:294 */
dup3
/* "yul_function_name_clashes_different_params/input.yul":286:298 */
sstore
/* "yul_function_name_clashes_different_params/input.yul":27:304 */
pop
pop
@@ -0,0 +1,13 @@
contract C {
function f() public pure returns (uint r) {
assembly { function f() -> x { x := 1 } r := f() }
}
function g() public pure returns (uint r) {
assembly { function f() -> x { x := 2 } r := f() }
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1
// g() -> 2