Source notes (Core support)
authorPeter Wortmann <scpmw@leeds.ac.uk>
Mon, 1 Dec 2014 19:21:47 +0000 (20:21 +0100)
committerAustin Seipp <austin@well-typed.com>
Tue, 16 Dec 2014 21:01:40 +0000 (15:01 -0600)
commit993975d3a532887b38618eb604efe6502f3c66f8
tree7b3ac0561fe537586f77e375f9a024f15db870cf
parent1b5d758359ef1fec6974d4d67eaf31599ec0309b
Source notes (Core support)

This patch introduces "SourceNote" tickishs that link Core to the
source code that generated it. The idea is to retain these source code
links throughout code transformations so we can eventually relate
object code all the way back to the original source (which we can,
say, encode as DWARF information to allow debugging).  We generate
these SourceNotes like other tickshs in the desugaring phase. The
activating command line flag is "-g", consistent with the flag other
compilers use to decide DWARF generation.

Keeping ticks from getting into the way of Core transformations is
tricky, but doable. The changes in this patch produce identical Core
in all cases I tested -- which at this point is GHC, all libraries and
nofib. Also note that this pass creates *lots* of tick nodes, which we
reduce somewhat by removing duplicated and overlapping source
ticks. This will still cause significant Tick "clumps" - a possible
future optimization could be to make Tick carry a list of Tickishs
instead of one at a time.

(From Phabricator D169)
29 files changed:
compiler/basicTypes/SrcLoc.hs
compiler/coreSyn/CoreArity.hs
compiler/coreSyn/CoreFVs.hs
compiler/coreSyn/CorePrep.hs
compiler/coreSyn/CoreSubst.hs
compiler/coreSyn/CoreSyn.hs
compiler/coreSyn/CoreUnfold.hs
compiler/coreSyn/CoreUtils.hs
compiler/coreSyn/PprCore.hs
compiler/deSugar/Coverage.hs
compiler/deSugar/Desugar.hs
compiler/iface/IfaceSyn.hs
compiler/iface/MkIface.hs
compiler/iface/TcIface.hs
compiler/main/DynFlags.hs
compiler/main/HscMain.hs
compiler/simplCore/CSE.hs
compiler/simplCore/FloatIn.hs
compiler/simplCore/FloatOut.hs
compiler/simplCore/OccurAnal.hs
compiler/simplCore/SetLevels.hs
compiler/simplCore/SimplCore.hs
compiler/simplCore/SimplEnv.hs
compiler/simplCore/SimplUtils.hs
compiler/simplCore/Simplify.hs
compiler/specialise/Rules.hs
compiler/specialise/SpecConstr.hs
compiler/stgSyn/CoreToStg.hs
compiler/utils/OrdList.hs