Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nim needs a way to find deadcode #245

Open
timotheecour opened this issue May 23, 2020 · 2 comments
Open

nim needs a way to find deadcode #245

timotheecour opened this issue May 23, 2020 · 2 comments

Comments

@timotheecour
Copy link
Owner

eg: in io.nim:

proc writeLn[Ty](f: File, x: varargs[Ty, `$`]) =
  for i in items(x):
    write(f, i)
  write(f, "\n")

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

@ringabout
Copy link
Collaborator

@timotheecour
Copy link
Owner Author

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 nim-lang#15827 (which doesn't require modifying sources) can be used as basis to solve problem A, but not problem B:

  • problem A: find code not used at RT (ie, code coverage doesn't see it)
  • problem B: find code that can't be reached from program start; eg:
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants