grain icon indicating copy to clipboard operation
grain copied to clipboard

Unused recursive functions aren't optimized away

Open ospencer opened this issue 3 years ago • 0 comments

Example:

for (let mut j = 0; j < 10; j += 1) {
  let rec foo = () => {
    print("never executed")
    foo()
  }
  void
}

foo is never called but the code to allocate the closure and the actual webassembly function are generated. The optimize_dead_assignments optimization doesn't consider that foo is recursive and counts the usage of foo inside the body of foo as a use.

ospencer avatar May 15 '22 22:05 ospencer