summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-09-19 11:16:55 -0400
committerBen Gamari <ben@smart-cactus.org>2017-09-19 13:37:46 -0400
commit12a92fedf8b1997f2e26800929be117d54536b7e (patch)
tree78456279bfcfffcd9d3eeb8ac4f96a3d9c22390a /compiler
parent8b007abbeb3045900a11529d907a835080129176 (diff)
downloadhaskell-12a92fedf8b1997f2e26800929be117d54536b7e.tar.gz
OccurAnal: Ensure SourceNotes don't interfere with join-point analysis
In general ticks are problematic for join point analysis as described in #14242. However, source notes are intended to be a best-effort annotation which shouldn't interfere with optimization. Special-case these to ensure that tail-call information is still correct, even in the presence of source note ticks. Test Plan: Validate Reviewers: simonpj, austin Reviewed By: simonpj Subscribers: rwbarton, thomie GHC Trac Issues: #14242 Differential Revision: https://phabricator.haskell.org/D3978
Diffstat (limited to 'compiler')
-rw-r--r--compiler/simplCore/OccurAnal.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/simplCore/OccurAnal.hs b/compiler/simplCore/OccurAnal.hs
index dace6a04c2..0c237cabe0 100644
--- a/compiler/simplCore/OccurAnal.hs
+++ b/compiler/simplCore/OccurAnal.hs
@@ -1723,6 +1723,12 @@ we can sort them into the right place when doing dependency analysis.
-}
occAnal env (Tick tickish body)
+ | SourceNote{} <- tickish
+ = (usage, Tick tickish body')
+ -- SourceNotes are best-effort; so we just proceed as usual.
+ -- If we drop a tick due to the issues described below it's
+ -- not the end of the world.
+
| tickish `tickishScopesLike` SoftScope
= (markAllNonTailCalled usage, Tick tickish body')
@@ -1742,6 +1748,7 @@ occAnal env (Tick tickish body)
-- Making j a join point may cause the simplifier to drop t
-- (if the tick is put into the continuation). So we don't
-- count j 1 as a tail call.
+ -- See #14242.
occAnal env (Cast expr co)
= case occAnal env expr of { (usage, expr') ->