[commit: ghc] master: OccurAnal: Ensure SourceNotes don't interfere with join-point analysis (12a92fe)

git at git.haskell.org git at git.haskell.org
Tue Sep 19 17:43:37 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/12a92fedf8b1997f2e26800929be117d54536b7e/ghc

>---------------------------------------------------------------

commit 12a92fedf8b1997f2e26800929be117d54536b7e
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Tue Sep 19 11:16:55 2017 -0400

    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


>---------------------------------------------------------------

12a92fedf8b1997f2e26800929be117d54536b7e
 compiler/simplCore/OccurAnal.hs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/compiler/simplCore/OccurAnal.hs b/compiler/simplCore/OccurAnal.hs
index dace6a0..0c237ca 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') ->



More information about the ghc-commits mailing list