summaryrefslogtreecommitdiff
path: root/compiler/simplCore/SetLevels.hs
diff options
context:
space:
mode:
authorPeter Wortmann <scpmw@leeds.ac.uk>2014-12-01 20:21:47 +0100
committerAustin Seipp <austin@well-typed.com>2014-12-16 15:01:40 -0600
commit993975d3a532887b38618eb604efe6502f3c66f8 (patch)
tree7b3ac0561fe537586f77e375f9a024f15db870cf /compiler/simplCore/SetLevels.hs
parent1b5d758359ef1fec6974d4d67eaf31599ec0309b (diff)
downloadhaskell-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/simplCore/SetLevels.hs')
-rw-r--r--compiler/simplCore/SetLevels.hs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/simplCore/SetLevels.hs b/compiler/simplCore/SetLevels.hs
index e7000409e7..c3ee112de4 100644
--- a/compiler/simplCore/SetLevels.hs
+++ b/compiler/simplCore/SetLevels.hs
@@ -592,6 +592,7 @@ notWorthFloating e abs_vars
go (_, AnnVar {}) n = n >= 0
go (_, AnnLit lit) n = ASSERT( n==0 )
litIsTrivial lit -- Note [Floating literals]
+ go (_, AnnTick t e) n = not (tickishIsCode t) && go e n
go (_, AnnCast e _) n = go e n
go (_, AnnApp e arg) n
| (_, AnnType {}) <- arg = go e n
@@ -606,6 +607,7 @@ notWorthFloating e abs_vars
is_triv (_, AnnCast e _) = is_triv e
is_triv (_, AnnApp e (_, AnnType {})) = is_triv e
is_triv (_, AnnApp e (_, AnnCoercion {})) = is_triv e
+ is_triv (_, AnnTick t e) = not (tickishIsCode t) && is_triv e
is_triv _ = False
{-