diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-08-15 22:28:13 +0200 |
---|---|---|
committer | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-09-28 15:13:29 +0200 |
commit | 365af22d75edd50edc657b6c4308824ae44f391f (patch) | |
tree | 08fd3b82c3023e9d27c4c8c24d45e9da7f5d5839 | |
parent | 2cf828e829011f103ea946756a0c53322fa238dd (diff) | |
download | haskell-wip/andreask/ghci-tags-94.tar.gz |
Fix GHCis interaction with tag inference.wip/andreask/ghci-tags-94
I had assumed that wrappers were not inlined in interactive mode.
Meaning we would always execute the compiled wrapper which properly
takes care of upholding the strict field invariant.
This turned out to be wrong. So instead we now run tag inference even
when we generate bytecode. In that case only for correctness not
performance reasons although it will be still beneficial for runtime
in some cases.
I further fixed a bug where GHCi didn't tag nullary constructors
properly when used as arguments. Which caused segfaults when calling
into compiled functions which expect the strict field invariant to
be upheld.
Fixes #22042 and #21083
This is the backport of !8840: Fix GHCis interaction with tag inference.
-------------------------
Metric Increase:
T4801
Metric Decrease:
T13035
-------------------------
-rw-r--r-- | compiler/GHC/Stg/InferTags/Rewrite.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/GHC/Stg/InferTags/Rewrite.hs b/compiler/GHC/Stg/InferTags/Rewrite.hs index ada3d38f10..2a77e5835a 100644 --- a/compiler/GHC/Stg/InferTags/Rewrite.hs +++ b/compiler/GHC/Stg/InferTags/Rewrite.hs @@ -25,7 +25,8 @@ import GHC.Types.Name import GHC.Types.Unique.Supply import GHC.Types.Unique.FM import GHC.Types.RepType -import GHC.Unit.Types (Module, isInteractiveModule) +import GHC.Types.Var.Set +import GHC.Unit.Types import GHC.Core.DataCon import GHC.Core (AltCon(..) ) @@ -216,7 +217,8 @@ withLcl fv act = do ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When compiling bytecode we call myCoreToStg to get STG code first. myCoreToStg in turn calls out to stg2stg which runs the STG to STG -passes followed by free variables analysis and tag inference at the end. +passes followed by free variables analysis and the tag inference pass including +it's rewriting phase at the end. Running tag inference is important as it upholds Note [Strict Field Invariant]. While code executed by GHCi doesn't take advantage of the SFI it can call into compiled code which does. So it must still make sure that the SFI is upheld. |