sheaf pushed to branch wip/debug-join-point at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Core/Opt/Simplify/Iteration.hs
    ... ... @@ -1905,7 +1905,7 @@ simplNonRecE :: HasDebugCallStack
    1905 1905
     -- Otherwise it may or may not satisfy it.
    
    1906 1906
     
    
    1907 1907
     simplNonRecE env from_what bndr (rhs, rhs_se) body cont
    
    1908
    -  | assert (isId bndr && not (isJoinId bndr) ) $
    
    1908
    +  | assert (isId bndr && isNothing (joinPointBinding_maybe bndr rhs)) $
    
    1909 1909
         is_strict_bind
    
    1910 1910
       = -- Evaluate RHS strictly
    
    1911 1911
         simplExprF (rhs_se `setInScopeFromE` env) rhs
    
    ... ... @@ -1943,7 +1943,7 @@ simplRecE :: SimplEnv
    1943 1943
     -- Precondition: not a join-point binding
    
    1944 1944
     simplRecE env pairs body cont
    
    1945 1945
       = do  { let bndrs = map fst pairs
    
    1946
    -        ; massert (all (not . isJoinId) bndrs)
    
    1946
    +        ; massert (isNothing $ joinPointBindings_maybe pairs)
    
    1947 1947
             ; env1 <- simplRecBndrs env bndrs
    
    1948 1948
                     -- NB: bndrs' don't have unfoldings or rules
    
    1949 1949
                     -- We add them as we go down
    

  • compiler/GHC/Core/SimpleOpt.hs
    ... ... @@ -1059,28 +1059,27 @@ and again its arity increases (#15517)
    1059 1059
     -}
    
    1060 1060
     
    
    1061 1061
     
    
    1062
    --- | Returns Just (bndr,rhs) if the binding is a join point:
    
    1063
    --- If it's a JoinId, just return it
    
    1064
    --- If it's not yet a JoinId but is always tail-called,
    
    1065
    ---    make it into a JoinId and return it.
    
    1066
    --- In the latter case, eta-expand the RHS if necessary, to make the
    
    1067
    --- lambdas explicit, as is required for join points
    
    1068
    ---
    
    1069
    --- Precondition: the InBndr has been occurrence-analysed,
    
    1070
    ---               so its OccInfo is valid
    
    1062
    +-- | Returns @Just (bndr,rhs)@ if the binding is a join point or can be made
    
    1063
    +-- into a join point (it is always tail called). In the latter case, eta-expand
    
    1064
    +-- the RHS if necessary, to make the lambdas explicit, as is required for join points.
    
    1071 1065
     joinPointBinding_maybe :: InBndr -> InExpr -> Maybe (InBndr, InExpr)
    
    1072 1066
     joinPointBinding_maybe bndr rhs
    
    1073 1067
       | not (isId bndr)
    
    1074 1068
       = Nothing
    
    1075 1069
     
    
    1070
    +  -- NB: the 'OccInfo' of the 'InBndr' may have been zapped, e.g. if we
    
    1071
    +  -- have inlined it. In this case, we may lose the join-point-hood of the
    
    1072
    +  -- original binder. A later occurrence analysis pass may recover it.
    
    1076 1073
       | isJoinId bndr
    
    1077
    -  = Just (bndr, rhs)
    
    1074
    +  = case tailCallInfo (idOccInfo bndr) of
    
    1075
    +      NoTailCallInfo -> Nothing
    
    1076
    +      AlwaysTailCalled {} -> Just (bndr, rhs)
    
    1078 1077
     
    
    1079 1078
       | AlwaysTailCalled join_arity <- tailCallInfo (idOccInfo bndr)
    
    1080 1079
       , (bndrs, body) <- etaExpandToJoinPoint join_arity rhs
    
    1081 1080
       , let str_sig   = idDmdSig bndr
    
    1082 1081
             str_arity = count isId bndrs  -- Strictness demands are for Ids only
    
    1083
    -        join_bndr = bndr `asJoinId`        join_arity
    
    1082
    +        join_bndr = bndr `asJoinId`    join_arity
    
    1084 1083
                              `setIdDmdSig` etaConvertDmdSig str_arity str_sig
    
    1085 1084
       = Just (join_bndr, mkLams bndrs body)
    
    1086 1085