CmmUtils: get rid of insertBlock
ClosedPublic

Authored by michalt on Mar 11 2018, 10:54 AM.

Details

Summary

Hoopl.Graph has almost exactly the same function, so let's use that.
Also, use IntMap.alter to make it more efficient.

Also switch Hoopl to use strict maps.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Test Plan

./validate

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
michalt created this revision.Mar 11 2018, 10:54 AM
dfeuer added a subscriber: dfeuer.Mar 11 2018, 10:12 PM
dfeuer added inline comments.
compiler/cmm/Hoopl/Collections.hs
15

Do you happen to know if Hoopl uses laziness in maps, or whether this should really be Data.IntMap.Strict? It might be worth experimenting with that.

michalt marked an inline comment as done.Mar 12 2018, 3:22 PM
michalt added inline comments.
compiler/cmm/Hoopl/Collections.hs
15

Hoopl internally doesn't use laziness in values of maps. (it generally doesn't use much laziness)
However, the maps are used outside Hoopl (cmm/ and nativeGen both use them). So I just tried changing this to Strict to see what happens :) It doesn't seem to break anything and results in just a bit less compiler allocation in a few nofib programs:

-1 s.d.                -----            -0.1%
+1 s.d.                -----            -0.0%
Average                -----            -0.0%
michalt updated this revision to Diff 15734.Mar 12 2018, 3:22 PM
michalt marked an inline comment as done.
  • Use IntMap.Strict in Hoopl

The strict and lazy modules export the same data structures. Only the
functions are different.

bgamari accepted this revision.Mar 13 2018, 1:06 PM

Lovely.

This revision is now accepted and ready to land.Mar 13 2018, 1:06 PM
bgamari edited the summary of this revision. (Show Details)Mar 13 2018, 1:06 PM
This revision was automatically updated to reflect the committed changes.