diff options
| author | Peter Wortmann <scpmw@leeds.ac.uk> | 2014-12-01 20:21:47 +0100 |
|---|---|---|
| committer | Austin Seipp <austin@well-typed.com> | 2014-12-16 15:01:40 -0600 |
| commit | 993975d3a532887b38618eb604efe6502f3c66f8 (patch) | |
| tree | 7b3ac0561fe537586f77e375f9a024f15db870cf /compiler/coreSyn/PprCore.hs | |
| parent | 1b5d758359ef1fec6974d4d67eaf31599ec0309b (diff) | |
| download | haskell-993975d3a532887b38618eb604efe6502f3c66f8.tar.gz | |
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)
Diffstat (limited to 'compiler/coreSyn/PprCore.hs')
| -rw-r--r-- | compiler/coreSyn/PprCore.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/coreSyn/PprCore.hs b/compiler/coreSyn/PprCore.hs index acc6c79fa1..59c5214581 100644 --- a/compiler/coreSyn/PprCore.hs +++ b/compiler/coreSyn/PprCore.hs @@ -29,6 +29,7 @@ import BasicTypes import Util import Outputable import FastString +import SrcLoc ( pprUserRealSpan ) {- ************************************************************************ @@ -216,7 +217,10 @@ ppr_expr add_par (Let bind expr) NonRec _ _ -> (sLit "let {") ppr_expr add_par (Tick tickish expr) - = add_par (sep [ppr tickish, pprCoreExpr expr]) + = sdocWithDynFlags $ \dflags -> + if gopt Opt_PprShowTicks dflags + then add_par (sep [ppr tickish, pprCoreExpr expr]) + else ppr_expr add_par expr pprCoreAlt :: OutputableBndr a => (AltCon, [a] , Expr a) -> SDoc pprCoreAlt (con, args, rhs) @@ -490,7 +494,7 @@ pprRule (Rule { ru_name = name, ru_act = act, ru_fn = fn, instance Outputable id => Outputable (Tickish id) where ppr (HpcTick modl ix) = - hcat [ptext (sLit "tick<"), + hcat [ptext (sLit "hpc<"), ppr modl, comma, ppr ix, ptext (sLit ">")] @@ -506,6 +510,8 @@ instance Outputable id => Outputable (Tickish id) where (True,True) -> hcat [ptext (sLit "scctick<"), ppr cc, char '>'] (True,False) -> hcat [ptext (sLit "tick<"), ppr cc, char '>'] _ -> hcat [ptext (sLit "scc<"), ppr cc, char '>'] + ppr (SourceNote span _) = + hcat [ ptext (sLit "src<"), pprUserRealSpan True span, char '>'] {- ----------------------------------------------------- |
