Merge pull request #8957 from ethereum/bug-blockdeduplicator

Fixed a bug in BlockDeDuplicator
This commit is contained in:
Harikrishnan Mulackal 2020-05-18 14:57:26 +05:30 committed by GitHub
commit 142a6b0d4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 133 additions and 1 deletions

View File

@ -9,7 +9,7 @@ Compiler Features:
Bugfixes:
* Optimizer: Fixed a bug in BlockDeDuplicator.
### 0.6.8 (2020-05-14)

View File

@ -113,6 +113,10 @@ bool BlockDeduplicator::applyTagReplacement(
if (subId != _subId)
continue;
auto it = _replacements.find(tagId);
// Recursively look for the element replaced by tagId
for (auto _it = it; _it != _replacements.end(); _it = _replacements.find(_it->second))
it = _it;
if (it != _replacements.end())
{
changed = true;

View File

@ -0,0 +1 @@
--optimize --asm --metadata-hash none

View File

@ -0,0 +1,11 @@
Warning: Statement has no effect.
--> optimizer_BlockDeDuplicator/input.sol:7:27:
|
7 | function f() public { true ? 1 : 3;}
| ^^^^^^^^^^^^
Warning: Function state mutability can be restricted to pure
--> optimizer_BlockDeDuplicator/input.sol:7:5:
|
7 | function f() public { true ? 1 : 3;}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {
function fun_x() public {}
function fun_() public {}
function f() public { true ? 1 : 3;}
function() r = true ? fun_x : f;
}

View File

@ -0,0 +1,107 @@
======= optimizer_BlockDeDuplicator/input.sol:C =======
EVM assembly:
/* "optimizer_BlockDeDuplicator/input.sol":60:213 contract C {... */
mstore(0x40, 0x80)
/* "optimizer_BlockDeDuplicator/input.sol":179:210 function() r = true ? fun_x : f */
0x00
dup1
sload
not(sub(shl(0x40, 0x01), 0x01))
and
/* "optimizer_BlockDeDuplicator/input.sol":201:206 fun_x */
or(tag_0_7, shl(0x20, tag_4))
sub(shl(0x40, 0x01), 0x01)
/* "optimizer_BlockDeDuplicator/input.sol":179:210 function() r = true ? fun_x : f */
and
or
swap1
sstore
/* "optimizer_BlockDeDuplicator/input.sol":60:213 contract C {... */
callvalue
/* "--CODEGEN--":2:4 */
dup1
iszero
tag_5
jumpi
/* "--CODEGEN--":27:28 */
0x00
/* "--CODEGEN--":24:25 */
dup1
/* "--CODEGEN--":17:29 */
revert
/* "--CODEGEN--":2:4 */
tag_5:
/* "optimizer_BlockDeDuplicator/input.sol":60:213 contract C {... */
pop
jump(tag_6)
/* "optimizer_BlockDeDuplicator/input.sol":77:103 function fun_x() public {} */
tag_4:
jump // out
/* "optimizer_BlockDeDuplicator/input.sol":60:213 contract C {... */
tag_6:
dataSize(sub_0)
dup1
dataOffset(sub_0)
0x00
codecopy
0x00
return
stop
sub_0: assembly {
/* "optimizer_BlockDeDuplicator/input.sol":60:213 contract C {... */
mstore(0x40, 0x80)
callvalue
/* "--CODEGEN--":5:14 */
dup1
/* "--CODEGEN--":2:4 */
iszero
tag_1
jumpi
/* "--CODEGEN--":27:28 */
0x00
/* "--CODEGEN--":24:25 */
dup1
/* "--CODEGEN--":17:29 */
revert
/* "--CODEGEN--":2:4 */
tag_1:
/* "optimizer_BlockDeDuplicator/input.sol":60:213 contract C {... */
pop
jumpi(tag_2, lt(calldatasize, 0x04))
shr(0xe0, calldataload(0x00))
dup1
0x26121ff0
eq
tag_3
jumpi
dup1
0x2e1fb2bc
eq
tag_3
jumpi
dup1
0x4753a67d
eq
tag_3
jumpi
tag_2:
/* "--CODEGEN--":12:13 */
0x00
/* "--CODEGEN--":9:10 */
dup1
/* "--CODEGEN--":2:14 */
revert
/* "optimizer_BlockDeDuplicator/input.sol":138:174 function f() public { true ? 1 : 3;} */
tag_3:
tag_6
tag_7
jump // in
tag_6:
stop
tag_7:
jump // out
auxdata: AUXDATA REMOVED
}