sheaf pushed to branch wip/andreask/ticked_joins at Glasgow Haskell Compiler / GHC

Commits:

5 changed files:

Changes:

  • compiler/GHC/Core/Lint.hs
    ... ... @@ -935,7 +935,12 @@ lintCoreExpr (Tick tickish expr)
    935 935
           --  ; when block_joins
    
    936 936
            ; pure r}
    
    937 937
       where
    
    938
    -    block_joins = not (tickishCanScopeJoin tickish)
    
    938
    +    block_joins
    
    939
    +      | ProfNote {} <- tickish
    
    940
    +      = False -- Turns a true join point into a quasi join point.
    
    941
    +              -- SLD TODO: proper Core Lint support for quasi join points.
    
    942
    +      | otherwise
    
    943
    +      = not (tickishCanScopeJoin tickish)
    
    939 944
           -- TODO Consider whether this is the correct rule. It is consistent with
    
    940 945
           -- the simplifier's behaviour - cost-centre-scoped ticks become part of
    
    941 946
           -- the continuation, and thus they behave like part of an evaluation
    

  • compiler/GHC/Core/Opt/Exitify.hs
    ... ... @@ -226,7 +226,7 @@ exitifyRec in_scope pairs
    226 226
                  let rhs   = mkLams abs_vars e
    
    227 227
                      avoid = in_scope `extendInScopeSetList` captured
    
    228 228
                  -- Remember this binding under a suitable name
    
    229
    -           ; v <- addExit avoid TrueJoinPoint (length abs_vars) rhs
    
    229
    +           ; v <- addExit avoid (length abs_vars) rhs
    
    230 230
                  -- And jump to it from here
    
    231 231
                ; return $ mkVarApps (Var v) abs_vars }
    
    232 232
     
    
    ... ... @@ -273,11 +273,11 @@ mkExitJoinId in_scope ty join_ty join_arity = do
    273 273
           asJoinId (mkSysLocal (fsLit "exit") initExitJoinUnique ManyTy ty)
    
    274 274
             join_ty join_arity
    
    275 275
     
    
    276
    -addExit :: InScopeSet -> JoinPointType -> JoinArity -> CoreExpr -> ExitifyM JoinId
    
    277
    -addExit in_scope join_ty join_arity rhs = do
    
    276
    +addExit :: InScopeSet -> JoinArity -> CoreExpr -> ExitifyM JoinId
    
    277
    +addExit in_scope join_arity rhs = do
    
    278 278
         -- Pick a suitable name
    
    279 279
         let ty = exprType rhs
    
    280
    -    v <- mkExitJoinId in_scope ty join_ty join_arity
    
    280
    +    v <- mkExitJoinId in_scope ty TrueJoinPoint join_arity
    
    281 281
         fs <- get
    
    282 282
         put ((v,rhs):fs)
    
    283 283
         return v
    

  • compiler/GHC/Core/Opt/OccurAnal.hs
    ... ... @@ -2299,7 +2299,7 @@ occ_anal_lam_tail env (Cast expr co)
    2299 2299
                         _ -> usage1
    
    2300 2300
     
    
    2301 2301
              -- usage3: see Note [Quasi join points] in GHC.Core.Opt.Simplify.Iteration.
    
    2302
    -         usage3 = markAllNonTail usage2 -- SLD TODO: markAllQuasiTail but this prevenst GHC bootstrapping
    
    2302
    +         usage3 = markAllQuasiTail usage2 -- SLD TODO
    
    2303 2303
     
    
    2304 2304
         in WUD usage3 (Cast expr' co)
    
    2305 2305
     
    
    ... ... @@ -2611,7 +2611,7 @@ occAnal env (Cast expr co)
    2611 2611
       = let (WUD usage expr') = occAnal env expr
    
    2612 2612
             usage1 = addManyOccs usage (coVarsOfCo co)
    
    2613 2613
                 -- usage1: see Note [Gather occurrences of coercion variables]
    
    2614
    -        usage2 = markAllNonTail usage1 -- SLD TODO: markAllQuasiTail but this prevenst GHC bootstrapping
    
    2614
    +        usage2 = markAllQuasiTail usage1 -- SLD TODO
    
    2615 2615
                 -- usage2: see Note [Quasi join points]
    
    2616 2616
         in WUD usage2 (Cast expr' co)
    
    2617 2617
     
    
    ... ... @@ -3874,8 +3874,10 @@ markAllManyNonTail = markAllMany . markAllNonTail -- effectively sets to noOccIn
    3874 3874
     
    
    3875 3875
     markAllNonTail ud@(UD { ud_env = env }) =
    
    3876 3876
       ud { ud_z_tail   = fmap (const MarkNonTail) env }
    
    3877
    -markAllQuasiTail ud@(UD { ud_env = env }) =
    
    3878
    -  ud { ud_z_tail   = fmap (const MarkQuasi) env }
    
    3877
    +markAllQuasiTail ud@(UD { ud_env = env, ud_z_tail = z_tail }) =
    
    3878
    +  let quasis = fmap (const MarkQuasi) env
    
    3879
    +  in ud { ud_z_tail   = strictPlusVarEnv_C (Semi.<>) quasis z_tail }
    
    3880
    +  -- NB: be careful not to override any MarkNonTail with MarkQuasi.
    
    3879 3881
     
    
    3880 3882
     markAllInsideLamIf, markAllNonTailIf :: HasDebugCallStack => Bool -> UsageDetails -> UsageDetails
    
    3881 3883
     
    

  • compiler/GHC/Core/Opt/Simplify/Iteration.hs
    ... ... @@ -2134,9 +2134,11 @@ trimJoinCont :: Id -- Used only in error message
    2134 2134
     trimJoinCont _ NotJoinPoint cont
    
    2135 2135
       = cont -- Not a jump
    
    2136 2136
     trimJoinCont var (JoinPoint { joinPointType = join_ty, joinPointArity = arity }) cont
    
    2137
    -  = assertPpr (join_ty == TrueJoinPoint)
    
    2138
    -      (text "trimJoinCont: unexpected quasi join point:" <+> ppr var) $
    
    2139
    -    trim arity cont
    
    2137
    +  | QuasiJoinPoint <- join_ty
    
    2138
    +  -- SLD TODO: not sure why we can end up here. Needs further investigation.
    
    2139
    +  = cont
    
    2140
    +  | otherwise
    
    2141
    +  = trim arity cont
    
    2140 2142
       where
    
    2141 2143
         trim 0 cont@(Stop {})
    
    2142 2144
           = cont
    

  • compiler/GHC/Types/Tickish.hs
    ... ... @@ -330,7 +330,8 @@ tickishCanSplit _ = False
    330 330
     -- | Is @join f x in <tick> jump f x@ valid?
    
    331 331
     tickishCanScopeJoin :: GenTickish pass -> Bool
    
    332 332
     tickishCanScopeJoin tick = case tick of
    
    333
    -  ProfNote{} -> True
    
    333
    +  ProfNote{} -> False -- Turns the join point into a quasi join point.
    
    334
    +                      -- See Note [Quasi join points]
    
    334 335
       HpcTick{} -> False
    
    335 336
       Breakpoint{} -> False
    
    336 337
       SourceNote{} -> True