Andreas Klebinger pushed to branch wip/andreask/ticked_joins at Glasgow Haskell Compiler / GHC Commits: 6c07295a by Andreas Klebinger at 2025-10-07T14:19:03+02:00 Use a predicate for joinablility - - - - - 3 changed files: - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Types/Tickish.hs Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -899,9 +899,12 @@ lintCoreExpr (Tick tickish expr) = do { case tickish of Breakpoint _ _ ids -> forM_ ids $ \id -> lintIdOcc id 0 _ -> return () - ; markAllJoinsBadIf block_joins $ lintCoreExpr expr } + ; expr_l <- lintCoreExpr expr + ; r <- markAllJoinsBadIf block_joins $ pure expr_l + -- ; when block_joins + ; pure r} where - block_joins = not (tickish `tickishScopesLike` SoftScope) + block_joins = not (tickishCanScopeJoin tickish) -- TODO Consider whether this is the correct rule. It is consistent with -- the simplifier's behaviour - cost-centre-scoped ticks become part of -- the continuation, and thus they behave like part of an evaluation ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -2493,7 +2493,7 @@ occAnal env (Tick tickish body) WUD usage body' = occAnal env body usage' - | tickish `tickishScopesLike` SoftScope || isProfTick tickish + | tickishCanScopeJoin tickish = usage -- For soft-scoped ticks (including SourceNotes) we don't want -- to lose join-point-hood, so we don't mess with `usage` (#24078) ===================================== compiler/GHC/Types/Tickish.hs ===================================== @@ -15,6 +15,7 @@ module GHC.Types.Tickish ( tickishScopesLike, tickishFloatable, tickishCanSplit, + tickishCanScopeJoin, mkNoCount, mkNoScope, tickishIsCode, @@ -324,6 +325,14 @@ tickishCanSplit ProfNote{profNoteScope = True, profNoteCount = True} = True tickishCanSplit _ = False +-- | Is @join f x in <tick> jump f x@ valid? +tickishCanScopeJoin :: GenTickish pass -> Bool +tickishCanScopeJoin tick = case tick of + ProfNote{} -> True + HpcTick{} -> False + Breakpoint{} -> False + SourceNote{} -> True + mkNoCount :: GenTickish pass -> GenTickish pass mkNoCount n | not (tickishCounts n) = n | not (tickishCanSplit n) = panic "mkNoCount: Cannot split!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c07295a064dcb495bdbd17f36a0ed29... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c07295a064dcb495bdbd17f36a0ed29... You're receiving this email because of your account on gitlab.haskell.org.