Open timotheecour opened 4 years ago
Related: https://github.com/jyapayne/mort
thanks for the pointer; I think this needs compiler support though. mort
requires users to modify their source code in a pretty invasive way.
I think https://github.com/nim-lang/Nim/pull/15827 (which doesn't require modifying sources) can be used as basis to solve problem A, but not problem B:
proc fn1(n: int)
proc fn2(n: int) =
if n>0: fn1(n-1)
proc fn1(n: int) =
if n>0: fn2(n-1)
proc main() = discard
main()
nim's DCE correctly cgen's main and doesn't cgen fn1,fn2 (not reachable by main even though both are being called by each other in their own cycle), which is good. But it doesn't provide a way to identify that fn1, fn2
are (statically) un-reachable in this program.
eg: in io.nim:
the tool should be robust to A calling B and A being deadcode, or to cycles of deadcode
it should be smart wrt conditional compilation