[Git][ghc/ghc][wip/romes/12935] Wait no that was way too slow...

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Fri Jun 21 14:06:12 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/12935 at Glasgow Haskell Compiler / GHC


Commits:
cf0a17ad by Rodrigo Mesquita at 2024-06-21T15:06:03+01:00
Wait no that was way too slow...

- - - - -


2 changed files:

- compiler/GHC/Cmm/Pipeline.hs
- compiler/GHC/Cmm/UniqueRenamer.hs


Changes:

=====================================
compiler/GHC/Cmm/Pipeline.hs
=====================================
@@ -31,6 +31,8 @@ import GHC.Utils.Misc ( partitionWithM )
 import GHC.Platform
 
 import Control.Monad
+import Data.List (mapAccumL)
+import Data.Bifunctor
 
 -----------------------------------------------------------------------------
 -- | Top level driver for C-- pipeline
@@ -47,7 +49,7 @@ cmmPipeline
  -> CmmGroup             -- Input C-- with Procedures
  -> IO (ModuleSRTInfo, (DetUniqFM, CmmGroupSRTs)) -- Output CPS transformed C--
 
-cmmPipeline logger cmm_config srtInfo detRnEnv0 prog = do
+cmmPipeline logger cmm_config srtInfo0 detRnEnv0 prog = do
   let forceRes (info, group) = info `seq` foldr seq () group
   let platform = cmmPlatform cmm_config
   withTimingSilent logger (text "Cmm pipeline") forceRes $ do
@@ -66,12 +68,14 @@ cmmPipeline logger cmm_config srtInfo detRnEnv0 prog = do
      -- We need to do this before SRT generation because otherwise we may look
      -- at the "old names" within the body of the function we are generating SRTs for.
      -- Easy easy: rename before and after.
-     (srtInfo, cmms) <- {-# SCC "doSRTs" #-} doSRTs cmm_config srtInfo procs data_
-     -- Easy easy: here we go.
-     let (detRnEnv2, (srtInfo_renamed, cmms_renamed)) = detRenameUniques detRnEnv1 (srtInfo, cmms)
-     dumpWith logger Opt_D_dump_cmm_cps "Post CPS Cmm (uniq-renamed)" FormatCMM (pdoc platform cmms_renamed)
-
-     return (srtInfo_renamed, (detRnEnv2, cmms_renamed))
+     -- Easy easy: but that turns out to be really slow, so let's try renaming
+     -- procs and data instead and hope srts are generated using names found there.
+     -- And don't rename procs just yet, ehhh
+     let (detRnEnv2, data_renamed) = mapAccumL (\rne (a,b) -> second (a,) $ detRenameUniques rne b) detRnEnv1 data_
+     (srtInfo1, cmms) <- {-# SCC "doSRTs" #-} doSRTs cmm_config srtInfo0 procs data_renamed
+     dumpWith logger Opt_D_dump_cmm_cps "Post CPS Cmm (uniq-renamed)" FormatCMM (pdoc platform cmms)
+
+     return (srtInfo1, (detRnEnv2, cmms))
 
 
 -- | The Cmm pipeline for a single 'CmmDecl'. Returns:


=====================================
compiler/GHC/Cmm/UniqueRenamer.hs
=====================================
@@ -132,6 +132,11 @@ instance UniqRenamable SRTEntry where
 instance UniqRenamable CAFfyLabel where
   uniqRename (CAFfyLabel cl) = CAFfyLabel <$> uniqRename cl
 
+instance UniqRenamable CmmDataDecl where
+  uniqRename (CmmData sec d)
+    = CmmData <$> uniqRename sec <*> uniqRename d
+  uniqRename _ = error "impossible"
+
 instance UniqRenamable CmmTopInfo where
   uniqRename TopInfo{info_tbls, stack_info}
     = TopInfo <$> uniqRename info_tbls <*> pure stack_info



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf0a17ad26a9ba46b0169a0b97cfa7696c02286c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf0a17ad26a9ba46b0169a0b97cfa7696c02286c
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240621/aea263bd/attachment-0001.html>


More information about the ghc-commits mailing list