[Git][ghc/ghc][wip/andreask/deduplicate-hsc-tidy] compiler: Deduplicate hscTidy
Andreas Klebinger pushed to branch wip/andreask/deduplicate-hsc-tidy at Glasgow Haskell Compiler / GHC Commits: 7e8b0d01 by Andreas Klebinger at 2026-06-16T10:36:13+02:00 compiler: Deduplicate hscTidy This function was accidentally duplicated during a refactor. Fixes #27351 - - - - - 3 changed files: - compiler/GHC/Driver/Main/Interactive.hs - compiler/GHC/Driver/Main/Passes.hs - compiler/GHC/Driver/Main/Passes.hs-boot Changes: ===================================== compiler/GHC/Driver/Main/Interactive.hs ===================================== @@ -31,7 +31,6 @@ module GHC.Driver.Main.Interactive , hscParseExpr , hscParseType , hscCompileCoreExpr - , hscTidy ) where @@ -39,7 +38,7 @@ import GHC.Prelude import GHC.Driver.Main.Hsc import {-# SOURCE #-} GHC.Driver.Main.Passes - ( hscDesugar', hscSimplify, hscCompileCoreExpr ) + ( hscDesugar', hscSimplify, hscTidy, hscCompileCoreExpr ) import {-# SOURCE #-} GHC.Driver.Main.Compile ( mkCgInteractiveGuts, generateFreshByteCodeLinkable ) @@ -47,11 +46,9 @@ import {-# SOURCE #-} GHC.Driver.Main.Compile import GHC.Driver.Session import GHC.Driver.Env import GHC.Driver.Errors.Types -import GHC.Driver.Config.Core.Lint ( endPassHscEnvIO ) import GHC.Driver.Config.Core.Lint.Interactive ( lintInteractiveExpr ) import GHC.Driver.Config.Parser (initParserOpts) import GHC.Driver.Config.Diagnostic -import GHC.Driver.Config.Tidy import GHC.Runtime.Context import GHCi.RemoteTypes @@ -66,16 +63,12 @@ import GHC.HsToCore import GHC.Iface.Load ( loadSysInterface ) -import GHC.Iface.Tidy import GHC.Core import GHC.Core.ConLike -import GHC.Core.Opt.Pipeline.Types ( CoreToDo (..)) import GHC.Core.TyCon import GHC.Core.InstEnv import GHC.Core.FamInstEnv -import GHC.Core.Rules -import GHC.Core.Stats import GHC.Parser.Errors.Types import GHC.Parser @@ -570,43 +563,3 @@ hscParseThingWithLocation source linenumber parser str = do FormatHaskell (showAstData NoBlankSrcSpan NoBlankEpAnnotations thing) return thing -hscTidy :: HscEnv -> ModGuts -> IO (CgGuts, ModDetails) -hscTidy hsc_env guts = do - let logger = hsc_logger hsc_env - let this_mod = mg_module guts - - opts <- initTidyOpts hsc_env - (cgguts, details) <- withTiming logger - (text "CoreTidy"<+>brackets (ppr this_mod)) - (const ()) - $! {-# SCC "CoreTidy" #-} tidyProgram opts guts - - -- post tidy pretty-printing and linting... - let tidy_rules = md_rules details - let all_tidy_binds = cg_binds cgguts - let name_ppr_ctx = mkNamePprCtx ptc (hsc_unit_env hsc_env) (mg_rdr_env guts) - ptc = initPromotionTickContext (hsc_dflags hsc_env) - - endPassHscEnvIO hsc_env name_ppr_ctx CoreTidy all_tidy_binds tidy_rules - - -- If the endPass didn't print the rules, but ddump-rules is - -- on, print now - unless (logHasDumpFlag logger Opt_D_dump_simpl) $ - putDumpFileMaybe logger Opt_D_dump_rules - "Tidy Core rules" - FormatText - (pprRulesForUser tidy_rules) - - -- Print one-line size info - let cs = coreBindsStats all_tidy_binds - putDumpFileMaybe logger Opt_D_dump_core_stats "Core Stats" - FormatText - (text "Tidy size (terms,types,coercions)" - <+> ppr (moduleName this_mod) <> colon - <+> int (cs_tm cs) - <+> int (cs_ty cs) - <+> int (cs_co cs)) - - pure (cgguts, details) - - ===================================== compiler/GHC/Driver/Main/Passes.hs ===================================== @@ -29,6 +29,7 @@ module GHC.Driver.Main.Passes , hscSimplify , hscSimplify' , hscDesugarAndSimplify + , hscTidy ) where ===================================== compiler/GHC/Driver/Main/Passes.hs-boot ===================================== @@ -7,6 +7,7 @@ module GHC.Driver.Main.Passes , hscDesugar' , hscSimplify + , hscTidy ) where @@ -24,9 +25,11 @@ import GHC.Tc.Utils.Monad import GHC.Unit import GHC.Unit.Module.ModGuts +import GHC.Unit.Module.ModDetails import GHC.Types.SrcLoc hscDesugar' :: ModLocation -> TcGblEnv -> Hsc ModGuts hscSimplify :: HscEnv -> [String] -> ModGuts -> IO ModGuts hscCompileCoreExpr :: HscEnv -> SrcSpan -> CoreExpr -> IO (ForeignHValue, [LinkableUsage], PkgsLoaded) +hscTidy :: HscEnv -> ModGuts -> IO (CgGuts, ModDetails) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7e8b0d017e62ada58917886355a9b79b... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7e8b0d017e62ada58917886355a9b79b... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Andreas Klebinger (@AndreasK)