[RFC] Core notes
Changes PlannedPublic

Authored by bgamari on Sep 4 2015, 5:29 AM.

Details

Reviewers
scpmw
austin
Summary

This patch was rebased and amended from @scpmw's profiling-ncg branch. It will be built upon D1214 and D1215 to implement a simple statistical profiler providing visibility into Core.

These tickishs are meant to carry the (simplified and prepared) Core
through the later compilation stages.

Notes:

  • Core notes are only useful in certain scenarios (mostly profiling), and will end up taking up significant space in object files. We therefore use another GHC flag (-fsave-core) to decide whether we annotate them or not.
  • Annotations happen after CorePrep. This is slightly tricky, as CoreToStg moves ticks around even after this point. We have to be careful to ensure ticks end up where we intend them to be.
  • We take the easy route to just "point" into the Core code directly. This is slightly awkward given that Core is normally a more stright- forward data structure. We have to short-circuit Eq/Ord, for example.
  • We only annotate the interesting control flow points, which are either top-level or let binding bodies as well as case branches.
  • In order to establish an identity and later perform sub-expression checks, we safe a binder (of the binding or case) and the case constructor (if applicable, otherwise __DEFAULT).
bgamari updated this revision to Diff 4062.Sep 4 2015, 5:29 AM
bgamari retitled this revision from to [RFC] Core notes.
bgamari updated this object.
bgamari edited the test plan for this revision. (Show Details)
bgamari added a reviewer: scpmw.
bgamari updated this object.Sep 4 2015, 7:23 AM
bgamari edited edge metadata.
bgamari updated this revision to Diff 4067.Sep 4 2015, 8:00 AM

Add documentation

osa1 added a subscriber: osa1.Sep 9 2015, 7:47 AM
osa1 added inline comments.
compiler/coreSyn/CoreSyn.hs
509

May I ask, where are Eq and Ord instances used and why is it safe to make all ExprPtrs equal?

docs/users_guide/phases.xml
738 ↗(On Diff #4067)

Minor typo here. (missing space, "informationfor")

scpmw edited edge metadata.Sep 10 2015, 10:08 AM

Currently there's no code even using this, so I presume this is just here for completeness' sake?

compiler/coreSyn/CoreSyn.hs
509

They aren't used - this is a crutch so Tickish (and therefore CoreExpr) can automatically be Eq+Ord, which if I remember correctly enables us to do CSE. However CoreNotes only exist for a very short time in the compilation process, so this code should not matter. It might make more sense to have it panic, actually.

@scpmw, that is correct. I have been playing around with using it locally. That being said, did you ever consider just inserting these notes into .debug_info using vendor-specific attributes? It seems like this is precisely the sort of case that DWARF's vendor extensibility is intended to address and I think it would simplify things if we only needed to walk one data structure rather than two.

bgamari planned changes to this revision.Sep 26 2015, 12:31 PM

I'm going to put this particular functionality aside for a while to focus on cleaning up the rest of the debugging/profiling effort.

austin resigned from this revision.Nov 6 2017, 10:10 PM