Nim icon indicating copy to clipboard operation
Nim copied to clipboard

WIP: Alternative move analyser that avoids the expensive creation of …

Open Araq opened this issue 3 years ago • 1 comments

…a control flow graph

Todo:

  • [x] fix the bug "break" does not leave the loop that owns the variable in question.
  • [x] fix the bug which prevents lastUse(obj.field) from working
  • [x] fix the remaining result false negatives
  • [x] fix false positive in symObj for proc fieldVisible.
  • [x] the move analyser must be smarter for this pattern:
  if cond:
    let a = result
    result = newNodeI(nkPragmaBlock, a.info)
  • [x] figure out why the algorithm doesn't understand closures properly
  • [x] use the algorithm from sempass2 to set nfFirstWrite.
  • [ ] enable the new analysers and make tests green again

Araq avatar Jul 10 '22 07:07 Araq

While it's nowhere near correct, here are numbers to justify its existence:

Old move analyser:

nim c --gc:orc --compileOnly compiler\nim.nim 162289 lines; 20.660s; 1.016GiB peakmem;

New move analyser:

nim c --gc:orc --compileOnly compiler\nim.nim 162094 lines; 13.596s; 1.016GiB peakmem;

Unfortunately no reduction in memory consumption was achieved. However, more than 6 seconds of compile-time improvement is nothing to complain about.

Araq avatar Jul 19 '22 07:07 Araq

The bootstrap failed because the compiler now bootstraps with -d:nimPreviewSystem. If you are using assert/doAssert, you need to add

when defined(nimPreviewSlimSystem):
  import std/assertions

When doing local bootstrap, disabled nimPreviewSlimSystem or use --lib:lib.

ringabout avatar Aug 10 '22 18:08 ringabout

Succeeded by https://github.com/nim-lang/Nim/pull/20471 which has fewer weird special cases, produces slightly better results and runs just as fast.

Araq avatar Oct 01 '22 13:10 Araq