[Git][ghc/ghc][master] compiler: fix generateCgIPEStub for no-tables-next-to-code builds

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Feb 14 16:35:29 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05:00
compiler: fix generateCgIPEStub for no-tables-next-to-code builds

generateCgIPEStub already correctly implements the CmmTick finding
logic for when tables-next-to-code is on/off, but it used the wrong
predicate to decide when to switch between the two. Previously it
switches based on whether the codegen is unregisterised, but there do
exist registerised builds that disable tables-next-to-code! This patch
corrects that problem. Fixes #22896.

- - - - -


1 changed file:

- compiler/GHC/Driver/GenerateCgIPEStub.hs


Changes:

=====================================
compiler/GHC/Driver/GenerateCgIPEStub.hs
=====================================
@@ -23,7 +23,7 @@ import GHC.Driver.Config.StgToCmm
 import GHC.Driver.Config.Cmm
 import GHC.Prelude
 import GHC.Runtime.Heap.Layout (isStackRep)
-import GHC.Settings (Platform, platformUnregisterised)
+import GHC.Settings (Platform, platformTablesNextToCode)
 import GHC.StgToCmm.Monad (getCmm, initC, runC, initFCodeState)
 import GHC.StgToCmm.Prof (initInfoTableProv)
 import GHC.StgToCmm.Types (CmmCgInfos (..), ModuleLFInfos)
@@ -52,13 +52,13 @@ by `generateCgIPEStub`.
 
 This leads to the question: How to figure out the source location of a return frame?
 
-While the lookup algorithms for registerised and unregisterised builds differ in details, they have in
+While the lookup algorithms when tables-next-to-code is on/off differ in details, they have in
 common that we want to lookup the `CmmNode.CmmTick` (containing a `SourceNote`) that is nearest
 (before) the usage of the return frame's label. (Which label and label type is used differs between
 these two use cases.)
 
-Registerised
-~~~~~~~~~~~~~
+With tables-next-to-code
+~~~~~~~~~~~~~~~~~~~~~~~~
 
 Let's consider this example:
 ```
@@ -117,10 +117,10 @@ sure as there are e.g. update frames, too) with it's label (`c18g` in the exampl
     `IpeSourceLocation`. (There are other `Tickish` constructors like `ProfNote` or `HpcTick`, these are
     ignored.)
 
-Unregisterised
-~~~~~~~~~~~~~
+Without tables-next-to-code
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-In unregisterised builds there is no return frame / continuation label in calls. The continuation (i.e. return
+When tables-next-to-code is off, there is no return frame / continuation label in calls. The continuation (i.e. return
 frame) is set in an explicit Cmm assignment. Thus the tick lookup algorithm has to be slightly different.
 
 ```
@@ -223,9 +223,9 @@ generateCgIPEStub hsc_env this_mod denv s = do
       if (isStackRep . cit_rep) infoTable
         then do
           let findFun =
-                if platformUnregisterised platform
-                  then findCmmTickishForForUnregistered (cit_lbl infoTable)
-                  else findCmmTickishForRegistered infoTableLabel
+                if platformTablesNextToCode platform
+                  then findCmmTickishWithTNTC infoTableLabel
+                  else findCmmTickishSansTNTC (cit_lbl infoTable)
               blocks = concatMap toBlockList (graphs cmmGroup)
           firstJusts $ map findFun blocks
         else Nothing
@@ -236,8 +236,8 @@ generateCgIPEStub hsc_env this_mod denv s = do
         go acc (CmmProc _ _ _ g) = g : acc
         go acc _ = acc
 
-    findCmmTickishForRegistered :: Label -> Block CmmNode C C -> Maybe IpeSourceLocation
-    findCmmTickishForRegistered label block = do
+    findCmmTickishWithTNTC :: Label -> Block CmmNode C C -> Maybe IpeSourceLocation
+    findCmmTickishWithTNTC label block = do
       let (_, middleBlock, endBlock) = blockSplit block
 
       isCallWithReturnFrameLabel endBlock label
@@ -255,8 +255,8 @@ generateCgIPEStub hsc_env this_mod denv s = do
         maybeTick (CmmTick (SourceNote span name)) = Just (span, name)
         maybeTick _ = Nothing
 
-    findCmmTickishForForUnregistered :: CLabel -> Block CmmNode C C -> Maybe IpeSourceLocation
-    findCmmTickishForForUnregistered cLabel block = do
+    findCmmTickishSansTNTC :: CLabel -> Block CmmNode C C -> Maybe IpeSourceLocation
+    findCmmTickishSansTNTC cLabel block = do
       let (_, middleBlock, _) = blockSplit block
       find cLabel (blockToList middleBlock) Nothing
       where



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b019a7ac8fc9059cc3213f6f95a2daef97ca442
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/20230214/dc3193fa/attachment-0001.html>


More information about the ghc-commits mailing list