[Git][ghc/ghc][wip/romes/12935] Fix bug triggered by static data generated during SRT

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon Jun 24 10:54:00 UTC 2024



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


Commits:
cc752c2b by Rodrigo Mesquita at 2024-06-24T11:53:51+01:00
Fix bug triggered by static data generated during SRT

- - - - -


2 changed files:

- compiler/GHC/Cmm/Info/Build.hs
- compiler/GHC/Cmm/UniqueRenamer.hs


Changes:

=====================================
compiler/GHC/Cmm/Info/Build.hs
=====================================
@@ -887,7 +887,7 @@ doSRTs
   -> IO (ModuleSRTInfo, [CmmDeclSRTs])
 
 doSRTs cfg moduleSRTInfo procs data_ = do
-  us <- mkSplitUniqSupply 'u'
+  us <- mkSplitUniqSupply 'u' -- ROMES:TODO: We could use a deterministic supply here? All names from here on out should be deterministic. Perhaps I could also grep for all supplies created after this point in its closure or somethinkg...
 
   let profile = cmmProfile cfg
 


=====================================
compiler/GHC/Cmm/UniqueRenamer.hs
=====================================
@@ -22,6 +22,8 @@ import GHC.Utils.Outputable as Outputable
 import Data.Tuple (swap)
 import qualified Data.Map as M
 import qualified Data.Set as S
+import GHC.Types.Id
+import GHC.Types.Name (isInternalName)
 
 {-
 --------------------------------------------------------------------------------
@@ -87,6 +89,14 @@ detRenameUniques dufm x = swap $ runState (uniqRename x) dufm
 detRenameCLabel :: CLabel -> DetRnM CLabel
 detRenameCLabel = mapInternalNonDetUniques renameDetUniq
 
+-- | We want to rename uniques in Ids, but ONLY internal ones.
+detRenameId :: Id -> DetRnM Id
+detRenameId i
+    | isInternalName (idName i)
+    = setIdUnique i <$> renameDetUniq (getUnique i)
+    | otherwise
+    = pure i
+
 --------------------------------------------------------------------------------
 -- Traversals
 --------------------------------------------------------------------------------
@@ -149,7 +159,10 @@ instance UniqRenamable CmmStatics where
 
 instance UniqRenamable CmmInfoTable where
   uniqRename CmmInfoTable{cit_lbl, cit_rep, cit_prof, cit_srt, cit_clo}
-      = CmmInfoTable <$> uniqRename cit_lbl <*> pure cit_rep <*> pure cit_prof <*> uniqRename cit_srt <*> pure cit_clo
+      = CmmInfoTable <$> uniqRename cit_lbl <*> pure cit_rep <*> pure cit_prof <*> uniqRename cit_srt <*>
+         (case cit_clo of
+            Nothing -> pure Nothing
+            Just (an_id, ccs) -> Just . (,ccs) <$> detRenameId an_id)
 
 instance UniqRenamable Section where
   uniqRename (Section ty lbl) = Section ty <$> uniqRename lbl



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cc752c2b5e1db51646d66032b78fb0eba229403d
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/20240624/c7c7e0ce/attachment-0001.html>


More information about the ghc-commits mailing list