[Git][ghc/ghc][wip/torsten.schmits/23612] Avoid substituting constructors for breakpoint FVs
Torsten Schmits (@torsten.schmits)
gitlab at gitlab.haskell.org
Thu Aug 3 10:34:56 UTC 2023
Torsten Schmits pushed to branch wip/torsten.schmits/23612 at Glasgow Haskell Compiler / GHC
Commits:
618372ce by Torsten Schmits at 2023-08-03T12:34:08+02:00
Avoid substituting constructors for breakpoint FVs
Fixes #23612
MR: !11026
The fingerprinting logic in Iface.Recomp gets the constructor's tycon as
an additional element of a decl group's dependency graph, although it's
not in its local OccEnv.
It's probably also generally nonsense to keep a constructor in the
inspectable breakpoint vars.
-------------------------
Metric Decrease:
T12234
T13035
-------------------------
- - - - -
4 changed files:
- compiler/GHC/Core/Subst.hs
- + testsuite/tests/codeGen/should_run/T23612.hs
- + testsuite/tests/codeGen/should_run/T23612.script
- testsuite/tests/codeGen/should_run/all.T
Changes:
=====================================
compiler/GHC/Core/Subst.hs
=====================================
@@ -592,9 +592,22 @@ substDVarSet subst@(Subst _ _ tv_env cv_env) fvs
------------------
substTickish :: Subst -> CoreTickish -> CoreTickish
substTickish subst (Breakpoint ext n ids modl)
- = Breakpoint ext n (mapMaybe do_one ids) modl
+ = Breakpoint ext n (filter not_datacon (mapMaybe do_one ids)) modl
where
do_one = getIdFromTrivialExpr_maybe . lookupIdSubst subst
+
+ -- If a variable is substituted with a constructor, there's no point in
+ -- inspecting it anymore, and it would cause problems with the dependency
+ -- computation when fingerprinting iface decls, since it pulls in the name
+ -- of the tycon even when it's not in the decl's OccEnv.
+ not_datacon s
+ | isId s
+ = case idDetails s of
+ DataConWorkId {} -> False
+ DataConWrapId {} -> False
+ _ -> True
+ | otherwise = True
+
substTickish _subst other = other
{- Note [Substitute lazily]
=====================================
testsuite/tests/codeGen/should_run/T23612.hs
=====================================
@@ -0,0 +1,11 @@
+module Main where
+
+data X = A1
+
+foo :: X -> ()
+foo A1 = ()
+
+bar :: X -> ()
+bar y = foo y
+
+main = seq (map bar [A1]) (return ())
=====================================
testsuite/tests/codeGen/should_run/T23612.script
=====================================
@@ -0,0 +1 @@
+:load T23612
=====================================
testsuite/tests/codeGen/should_run/all.T
=====================================
@@ -237,3 +237,5 @@ test('MulMayOflo_full',
ignore_stdout],
multi_compile_and_run,
['MulMayOflo', [('MulMayOflo_full.cmm', '')], ''])
+
+test('T23612', only_ways(['ghci-opt']), ghci_script, ['T23612.script'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/618372ce380ea89c744e7ae2529eadeb52cc5ef2
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/618372ce380ea89c744e7ae2529eadeb52cc5ef2
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/20230803/e105bde9/attachment-0001.html>
More information about the ghc-commits
mailing list