mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Support unassigned variables in the SSA value tracker and the data flow analyzer.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
{
|
||||
// This does not replace b by a because there is no
|
||||
// explicit assignment, even though both hold the same value.
|
||||
let a
|
||||
let b
|
||||
mstore(sub(a, b), 7)
|
||||
}
|
||||
// ----
|
||||
// commonSubexpressionEliminator
|
||||
// {
|
||||
// let a
|
||||
// let b
|
||||
// mstore(sub(a, b), 7)
|
||||
// }
|
||||
@@ -1,5 +1,4 @@
|
||||
// c & d can't be optimized as expression simplifier doesn't handle default
|
||||
// values yet
|
||||
// Unassigned variables are assumed to be zero.
|
||||
{
|
||||
let c, d
|
||||
let y := add(d, add(c, 7))
|
||||
@@ -8,5 +7,5 @@
|
||||
// expressionSimplifier
|
||||
// {
|
||||
// let c, d
|
||||
// let y := add(add(d, c), 7)
|
||||
// let y := 7
|
||||
// }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// c & d can't be optimized as expression simplifier doesn't handle default
|
||||
// values yet
|
||||
// Unassigned variables are assumed to be zero.
|
||||
{
|
||||
let c
|
||||
let d
|
||||
@@ -10,5 +9,5 @@
|
||||
// {
|
||||
// let c
|
||||
// let d
|
||||
// let y := add(add(d, c), 7)
|
||||
// let y := 7
|
||||
// }
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
let r := f(a)
|
||||
// This should be inlined because it is a constant
|
||||
let t := f(a2)
|
||||
let a3
|
||||
// This should be inlined because it is a constant as well (zero)
|
||||
let s := f(a3)
|
||||
}
|
||||
// ----
|
||||
// fullInliner
|
||||
@@ -30,6 +33,16 @@
|
||||
// let f_y := add(f_a, f_x)
|
||||
// sstore(f_y, 10)
|
||||
// let t := f_b
|
||||
// let a3
|
||||
// let f_a_5 := a3
|
||||
// let f_b_6
|
||||
// let f_x_7 := mload(f_a_5)
|
||||
// f_b_6 := sload(f_x_7)
|
||||
// let f_c_8 := 3
|
||||
// mstore(mul(f_a_5, f_b_6), mload(f_x_7))
|
||||
// let f_y_11 := add(f_a_5, f_x_7)
|
||||
// sstore(f_y_11, 10)
|
||||
// let s := f_b_6
|
||||
// }
|
||||
// function f(a) -> b
|
||||
// {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
let x, y
|
||||
if x { mstore(0, 0) }
|
||||
if y { mstore(0, 0) }
|
||||
}
|
||||
// ----
|
||||
// structuralSimplifier
|
||||
// {
|
||||
// let x, y
|
||||
// }
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
let x
|
||||
if x { mstore(0, 0) }
|
||||
}
|
||||
// ----
|
||||
// structuralSimplifier
|
||||
// {
|
||||
// let x
|
||||
// }
|
||||
Reference in New Issue
Block a user