diff options
author | Cheng Shao <terrorjack@type.dance> | 2023-02-19 15:23:28 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-02-20 10:35:30 -0500 |
commit | 2592ab6924ee34ed0f0d82a7cb0aed393d93bb14 (patch) | |
tree | c7aa06f15dc3597a9e80d7fa010d3db3cac29ce7 | |
parent | 7080a93fd09b71aa6c94e6336eb054e9f5592932 (diff) | |
download | haskell-2592ab6924ee34ed0f0d82a7cb0aed393d93bb14.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.
-rw-r--r-- | compiler/GHC/CmmToAsm/Wasm/FromCmm.hs | 3 | ||||
-rw-r--r-- | rts/wasm/Wasm.S | 7 |
2 files changed, 1 insertions, 9 deletions
diff --git a/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs b/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs index 76411bfe65..59d183341b 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: - |