summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <terrorjack@type.dance>2023-02-13 13:54:10 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2023-02-20 09:32:09 +0000
commit220504f80f5cf7a457f1039c6570806ed75f2bd3 (patch)
tree50674fecec9feb81e82c20398806d27873d70018
parent448699f8a34f845558c77b3777d713f4fb37332c (diff)
downloadhaskell-220504f80f5cf7a457f1039c6570806ed75f2bd3.tar.gz
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. (cherry picked from commit 3b019a7ac8fc9059cc3213f6f95a2daef97ca442)
-rw-r--r--compiler/GHC/Driver/GenerateCgIPEStub.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/compiler/GHC/Driver/GenerateCgIPEStub.hs b/compiler/GHC/Driver/GenerateCgIPEStub.hs
index 40927bbc6e..d6e65aa53f 100644
--- a/compiler/GHC/Driver/GenerateCgIPEStub.hs
+++ b/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