summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <terrorjack@type.dance>2023-02-19 15:23:28 +0000
committerBen Gamari <ben@smart-cactus.org>2023-02-22 16:18:56 -0500
commit7dc43beb277d1c2801ea8bf9afaeb83dba2d19ac (patch)
tree314376f0755a80a616a8f73f6c2f35ee4f067237
parent88b18b0f855839610f33955b10fc7b3e871ab8c7 (diff)
downloadhaskell-7dc43beb277d1c2801ea8bf9afaeb83dba2d19ac.tar.gz
compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping
The wasm NCG used to map CCCS to a wasm global, based on the observation that CCCS is a transient register that's already handled by thread state load/store logic, so it doesn't need to be backed by the rCCCS field in the register table. Unfortunately, this is wrong, since even when Cmm execution hasn't yielded back to the scheduler, the Cmm code may call enterFunCCS, which does use rCCCS. This breaks cost centre profiling in a subtle way, resulting in inaccurate stack traces in some test cases. The fix is simple though: just remove the CCCS mapping. (cherry picked from commit 2592ab6924ee34ed0f0d82a7cb0aed393d93bb14)
-rw-r--r--compiler/GHC/CmmToAsm/Wasm/FromCmm.hs3
-rw-r--r--rts/wasm/Wasm.S7
2 files changed, 1 insertions, 9 deletions
diff --git a/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs b/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
index 8e4f285d27..f50c91aec2 100644
--- a/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
+++ b/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
@@ -191,7 +191,6 @@ globalInfoFromCmmGlobalReg t reg = case reg of
SpLim -> Just ("__SpLim", ty_word)
Hp -> Just ("__Hp", ty_word)
HpLim -> Just ("__HpLim", ty_word)
- CCCS -> Just ("__CCCS", ty_word)
_ -> Nothing
where
ty_word = SomeWasmType t
@@ -202,7 +201,7 @@ supportedCmmGlobalRegs =
<> [FloatReg i | i <- [1 .. 6]]
<> [DoubleReg i | i <- [1 .. 6]]
<> [LongReg i | i <- [1 .. 1]]
- <> [Sp, SpLim, Hp, HpLim, CCCS]
+ <> [Sp, SpLim, Hp, HpLim]
-- | Truncate a subword.
truncSubword :: Width -> WasmTypeTag t -> WasmExpr w t -> WasmExpr w t
diff --git a/rts/wasm/Wasm.S b/rts/wasm/Wasm.S
index a2321c0b63..3f5ad36f5d 100644
--- a/rts/wasm/Wasm.S
+++ b/rts/wasm/Wasm.S
@@ -169,10 +169,3 @@ __Hp:
.section .data.__HpLim,"",@
.globaltype __HpLim, W_
__HpLim:
-
- .hidden __CCCS
- .globl __CCCS
- .section .data.__CCCS,"",@
- .globaltype __CCCS, W_
-__CCCS:
-