mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
CodeGen: Only output switch when it has cases
This commit is contained in:
parent
76f31e2c4e
commit
454860d1f5
@ -15,6 +15,7 @@ Bugfixes:
|
||||
* Commandline Interface: Report output selection options unsupported by the selected input mode instead of ignoring them.
|
||||
* SMTChecker: Fix internal error in magic type access (``block``, ``msg``, ``tx``).
|
||||
* TypeChecker: Fix internal error when using user defined value types in public library functions.
|
||||
* Yul IR Generator: Do not output empty switches/if-bodies for empty contracts.
|
||||
|
||||
|
||||
|
||||
|
@ -944,7 +944,7 @@ string IRGenerator::callValueCheck()
|
||||
string IRGenerator::dispatchRoutine(ContractDefinition const& _contract)
|
||||
{
|
||||
Whiskers t(R"X(
|
||||
if iszero(lt(calldatasize(), 4))
|
||||
<?+cases>if iszero(lt(calldatasize(), 4))
|
||||
{
|
||||
let selector := <shr224>(calldataload(0))
|
||||
switch selector
|
||||
@ -962,8 +962,8 @@ string IRGenerator::dispatchRoutine(ContractDefinition const& _contract)
|
||||
}
|
||||
</cases>
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { <receiveEther> }
|
||||
}</+cases>
|
||||
<?+receiveEther>if iszero(calldatasize()) { <receiveEther> }</+receiveEther>
|
||||
<fallback>
|
||||
)X");
|
||||
t("shr224", m_utils.shiftRightFunction(224));
|
||||
|
@ -44,14 +44,6 @@ object "C_2" {
|
||||
/// @src 0:265:278 "contract C {}"
|
||||
mstore(64, 128)
|
||||
|
||||
if iszero(lt(calldatasize(), 4))
|
||||
{
|
||||
let selector := shift_right_224_unsigned(calldataload(0))
|
||||
switch selector
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
@ -175,7 +167,7 @@ object "D_27" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
@ -413,14 +405,6 @@ object "D_27" {
|
||||
/// @src 0:265:278 "contract C {}"
|
||||
mstore(64, 128)
|
||||
|
||||
if iszero(lt(calldatasize(), 4))
|
||||
{
|
||||
let selector := shift_right_224_unsigned(calldataload(0))
|
||||
switch selector
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
@ -499,7 +483,7 @@ object "D_27" {
|
||||
revert(pos, returndatasize())
|
||||
}
|
||||
mstore(add(allocate_memory_array_string(), 32), "/*")
|
||||
let memPtr := allocate_memory_array_string_482()
|
||||
let memPtr := allocate_memory_array_string_480()
|
||||
mstore(add(memPtr, 32), 0x2f2a2a204073726320303a39363a313635202022636f6e74726163742044207b)
|
||||
mstore(add(memPtr, 64), shl(200, 0x2e2e2e22202a2f))
|
||||
let memPos := mload(64)
|
||||
@ -540,7 +524,7 @@ object "D_27" {
|
||||
memPtr := memPtr_1
|
||||
mstore(memPtr_1, 2)
|
||||
}
|
||||
function allocate_memory_array_string_482() -> memPtr
|
||||
function allocate_memory_array_string_480() -> memPtr
|
||||
{
|
||||
let memPtr_1 := mload(64)
|
||||
let newFreePtr := add(memPtr_1, 96)
|
||||
|
@ -63,7 +63,7 @@ object "C_81" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -49,7 +49,7 @@ object "C_59" {
|
||||
for { } lt(src, srcEnd) { src := add(src, _2) }
|
||||
{
|
||||
if slt(sub(calldatasize(), src), _2) { revert(_1, _1) }
|
||||
let value := allocate_memory_1174()
|
||||
let value := allocate_memory_1172()
|
||||
mstore(value, calldataload(src))
|
||||
mstore(dst, value)
|
||||
dst := add(dst, _2)
|
||||
@ -67,7 +67,7 @@ object "C_59" {
|
||||
mstore(4, 0x41)
|
||||
revert(0, 0x24)
|
||||
}
|
||||
function allocate_memory_1174() -> memPtr
|
||||
function allocate_memory_1172() -> memPtr
|
||||
{
|
||||
memPtr := mload(64)
|
||||
let newFreePtr := add(memPtr, 32)
|
||||
|
@ -78,7 +78,7 @@ object "C_15" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -218,7 +218,7 @@ object \"C_54\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
@ -639,7 +639,7 @@ object \"C_54\" {
|
||||
case 0x26121ff0 {
|
||||
if callvalue() { revert(_1, _1) }
|
||||
abi_decode(calldatasize())
|
||||
let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_568(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\"))
|
||||
let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_566(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\"))
|
||||
/// @src 0:79:435 \"contract C...\"
|
||||
let memPos := mload(64)
|
||||
return(memPos, sub(abi_encode_int256(memPos, ret), memPos))
|
||||
@ -663,7 +663,7 @@ object \"C_54\" {
|
||||
if callvalue() { revert(_1, _1) }
|
||||
abi_decode(calldatasize())
|
||||
let memPos_3 := mload(64)
|
||||
return(memPos_3, sub(abi_encode_int256_567(memPos_3), memPos_3))
|
||||
return(memPos_3, sub(abi_encode_int256_565(memPos_3), memPos_3))
|
||||
}
|
||||
}
|
||||
revert(0, 0)
|
||||
@ -672,7 +672,7 @@ object \"C_54\" {
|
||||
{
|
||||
if slt(add(dataEnd, not(3)), 0) { revert(0, 0) }
|
||||
}
|
||||
function abi_encode_int256_567(headStart) -> tail
|
||||
function abi_encode_int256_565(headStart) -> tail
|
||||
{
|
||||
tail := add(headStart, 32)
|
||||
mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29)
|
||||
@ -689,7 +689,7 @@ object \"C_54\" {
|
||||
mstore(4, 0x11)
|
||||
revert(0, 0x24)
|
||||
}
|
||||
function checked_add_int256_568(y) -> sum
|
||||
function checked_add_int256_566(y) -> sum
|
||||
{
|
||||
if and(1, sgt(y, sub(shl(255, 1), 42))) { panic_error_0x11() }
|
||||
sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 0:79:435 \"contract C...\" */ y)
|
||||
@ -1050,7 +1050,7 @@ object \"D_72\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
@ -1479,7 +1479,7 @@ object \"D_72\" {
|
||||
case 0x26121ff0 {
|
||||
if callvalue() { revert(_1, _1) }
|
||||
abi_decode(calldatasize())
|
||||
let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_568(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\"))
|
||||
let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_566(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\"))
|
||||
/// @src 1:91:166 \"contract D is C(3)...\"
|
||||
let memPos := mload(64)
|
||||
return(memPos, sub(abi_encode_int256(memPos, ret), memPos))
|
||||
@ -1503,7 +1503,7 @@ object \"D_72\" {
|
||||
if callvalue() { revert(_1, _1) }
|
||||
abi_decode(calldatasize())
|
||||
let memPos_3 := mload(64)
|
||||
return(memPos_3, sub(abi_encode_int256_567(memPos_3), memPos_3))
|
||||
return(memPos_3, sub(abi_encode_int256_565(memPos_3), memPos_3))
|
||||
}
|
||||
}
|
||||
revert(0, 0)
|
||||
@ -1512,7 +1512,7 @@ object \"D_72\" {
|
||||
{
|
||||
if slt(add(dataEnd, not(3)), 0) { revert(0, 0) }
|
||||
}
|
||||
function abi_encode_int256_567(headStart) -> tail
|
||||
function abi_encode_int256_565(headStart) -> tail
|
||||
{
|
||||
tail := add(headStart, 32)
|
||||
mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29)
|
||||
@ -1529,7 +1529,7 @@ object \"D_72\" {
|
||||
mstore(4, 0x11)
|
||||
revert(0, 0x24)
|
||||
}
|
||||
function checked_add_int256_568(y) -> sum
|
||||
function checked_add_int256_566(y) -> sum
|
||||
{
|
||||
if and(1, sgt(y, sub(shl(255, 1), 42))) { panic_error_0x11() }
|
||||
sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 1:91:166 \"contract D is C(3)...\" */ y)
|
||||
|
@ -47,7 +47,6 @@ object \"C_7\" {
|
||||
}
|
||||
default { }
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
function shift_right_224_unsigned(value) -> newValue
|
||||
{ newValue := shr(224, value) }
|
||||
|
@ -62,7 +62,7 @@ object \"C_7\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -43,14 +43,6 @@ object \"C_3\" {
|
||||
/// @src 0:79:92 \"contract C {}\"
|
||||
mstore(64, 128)
|
||||
|
||||
if iszero(lt(calldatasize(), 4))
|
||||
{
|
||||
let selector := shift_right_224_unsigned(calldataload(0))
|
||||
switch selector
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
@ -139,7 +131,7 @@ object \"D_16\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
@ -253,14 +245,6 @@ object \"D_16\" {
|
||||
/// @src 0:79:92 \"contract C {}\"
|
||||
mstore(64, 128)
|
||||
|
||||
if iszero(lt(calldatasize(), 4))
|
||||
{
|
||||
let selector := shift_right_224_unsigned(calldataload(0))
|
||||
switch selector
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -63,7 +63,7 @@ object "test_11" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -31,16 +31,8 @@ object "C_7" {
|
||||
{
|
||||
/// @src 0:80:112 "contract C..."
|
||||
mstore(64, 128)
|
||||
if iszero(lt(calldatasize(), 4))
|
||||
{
|
||||
let selector := shift_right_unsigned(calldataload(0))
|
||||
pop(selector)
|
||||
}
|
||||
pop(iszero(calldatasize()))
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
}
|
||||
function shift_right_unsigned(value) -> newValue
|
||||
{ newValue := shr(224, value) }
|
||||
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
{ revert(0, 0) }
|
||||
}
|
||||
|
@ -138,7 +138,6 @@ object "C_6" {
|
||||
return(memPos, sub(memEnd, memPos))
|
||||
}
|
||||
}
|
||||
pop(iszero(calldatasize()))
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
}
|
||||
function shift_right_unsigned(value) -> newValue
|
||||
|
@ -62,7 +62,7 @@ object \"C_11\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -62,7 +62,7 @@ object \"C_11\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -62,7 +62,7 @@ object \"C_11\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -62,7 +62,7 @@ object \"C_11\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
@ -62,7 +62,7 @@ object \"C_11\" {
|
||||
|
||||
default {}
|
||||
}
|
||||
if iszero(calldatasize()) { }
|
||||
|
||||
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
|
||||
|
||||
function shift_right_224_unsigned(value) -> newValue {
|
||||
|
Loading…
Reference in New Issue
Block a user