Scribe icon indicating copy to clipboard operation
Scribe copied to clipboard

Dead Memory

Open ControlCplusControlV opened this issue 3 years ago • 1 comments

ControlCplusControlV avatar Dec 17 '22 22:12 ControlCplusControlV

Dead Memory

If a value is stored in memory, once it's location is never read from again the compiler can consider that memory as "free," and overwrite it

Test Cases

  1. Yul Input
{
    let x:u32 := 700
    mstore(0x100, x)

    let z := mload(0x100)
    let y:u32 := 100

    let a := add(z, y)
    mstore(0x200, a)
}
  1. Assembly Output
//Should store `a` at memory slot 0x100

ControlCplusControlV avatar Dec 17 '22 22:12 ControlCplusControlV