Skip to content
Snippets Groups Projects

driver: Fix recompilation checking for exported defaults and COMPLETE pragmas

Open Matthew Pickering requested to merge wip/fix-recomp-complete-export into master
9 unresolved threads
A {-# COMPLETE P, Q #-} pragma is associated with the pattern synonyms P
and Q during recompilation checking. Therefore, the existence of a
pattern synonym becomes part of the ABI hash for P and Q.

Then if a module uses these pattern synonyms and a complete pragma
changes, it will trigger recompilation in that module.

Fixes #25854 

and

Since the exported defaults are not associated with any identifier from
the module, they are just added to the export hash rather than
the fine-grained recompilation logic.

Fixes #25855

Merge request reports

Approval is optional
Test summary results are being parsed
Ready to merge by members who can write to the target branch.

Merge details

  • The source branch is 61 commits behind the target branch.
  • 1 commit and 1 merge commit will be added to .
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1290 1290
1291 1291 -- the export list hash doesn't depend on the fingerprints of
1292 1292 -- the Names it mentions, only the Names themselves, hence putNameLiterally.
1293
1294 -- The export hash is for things which is anything changes, modules which depend on
1295 -- it will be recompiled.
  • Comment on lines +1294 to +1295
    Suggested change
    1295 -- The export hash is for things which is anything changes, modules which depend on
    1296 -- it will be recompiled.
    1295 -- The export hash is for things which require downstream modules to be recompiled
    1296 -- whenever they change, e.g.:
    1297 -- - a change in the export list (adding a new export might cause a name clash)
    1298 -- - a change in exported instances (whether orphans or not)
  • Please register or sign in to reply
  • sheaf
    sheaf @sheaf started a thread on commit 6d0a5d00
  • 489 489
    490 490 mkIfaceCompleteMatch :: CompleteMatch -> IfaceCompleteMatch
    491 491 mkIfaceCompleteMatch (CompleteMatch cls mtc) =
    492 IfaceCompleteMatch (uniqDSetToList cls) mtc
    492 -- NB: Sorting here means that COMPLETE {P, Q} and COMPLETE {Q, P} are identified
    493 -- for recompilation checking.
    • Comment on lines +492 to +493
      Suggested change
      492 -- NB: Sorting here means that COMPLETE {P, Q} and COMPLETE {Q, P} are identified
      493 -- for recompilation checking.
      492 -- NB: Sorting here means that COMPLETE {P, Q} and COMPLETE {Q, P} are
      493 -- considered identical, in particular for recompilation checking.
    • Please register or sign in to reply
  • sheaf
    sheaf @sheaf started a thread on commit 6d0a5d00
  • 1453 1454 -- See Note [Orphans] in GHC.Core.InstEnv
    1454 1455 [AnnPayload] -- Annotations of the type itself
    1455 1456 [IfaceIdExtras] -- For each constructor: fixity, RULES and annotations
    1457 [IfaceCompleteMatch] -- COMPLETE pragmas for the type
    • Suggested change
      1457 [IfaceCompleteMatch] -- COMPLETE pragmas for the type
      1457 [IfaceCompleteMatch] -- ^ COMPLETE pragmas that DataCons of this TyCon appear in
    • Please register or sign in to reply
  • sheaf
    sheaf @sheaf started a thread on commit 6d0a5d00
  • 1472 1474
    1473 1475 | IfaceFamilyExtras (Maybe Fixity) [IfaceInstABI] [AnnPayload]
    1474 1476
    1477 | IfacePatSynExtras (Maybe Fixity) [IfaceCompleteMatch]
    • Suggested change
      1477 | IfacePatSynExtras (Maybe Fixity) [IfaceCompleteMatch]
      1477 | IfacePatSynExtras (Maybe Fixity) [IfaceCompleteMatch] -- ^ COMPLETE pragmas that this PatSyn appears in
    • Please register or sign in to reply
  • sheaf
    sheaf @sheaf started a thread on commit 6d0a5d00
  • 1090 1090 (non_orph_insts, orph_insts) = mkOrphMap ifInstOrph insts
    1091 1091 (non_orph_rules, orph_rules) = mkOrphMap ifRuleOrph rules
    1092 1092 (non_orph_fis, orph_fis) = mkOrphMap ifFamInstOrph fam_insts
    1093 non_complete_matches = mkIfaceCompleteMap complete
    • Suggested change
      1093 non_complete_matches = mkIfaceCompleteMap complete
      1093 complete_matches = mkIfaceCompleteMap complete
    • Please register or sign in to reply
  • sheaf
    sheaf @sheaf started a thread on commit 6d0a5d00
  • 1100 1101 -- See also Note [Identity versus semantic module]
    1101 1102 declABI decl = (this_mod, decl, extras)
    1102 1103 where extras = declExtras fix_fn ann_fn non_orph_rules non_orph_insts
    1103 non_orph_fis top_lvl_name_env decl
    1104 non_orph_fis top_lvl_name_env non_complete_matches decl
    • Suggested change
      1104 non_orph_fis top_lvl_name_env non_complete_matches decl
      1104 non_orph_fis top_lvl_name_env complete_matches decl
    • Please register or sign in to reply
  • sheaf
    sheaf @sheaf started a thread on commit 6d0a5d00
  • 1500 1504 freeNamesDeclExtras :: IfaceDeclExtras -> NameSet
    1501 1505 freeNamesDeclExtras (IfaceIdExtras id_extras)
    1502 1506 = freeNamesIdExtras id_extras
    1503 freeNamesDeclExtras (IfaceDataExtras _ insts _ subs)
    1504 = unionNameSets (mkNameSet insts : map freeNamesIdExtras subs)
    1507 freeNamesDeclExtras (IfaceDataExtras _ insts _ subs complete)
    1508 = unionNameSets (mkNameSet insts : map freeNamesIdExtras subs ++ map freeNamesIfCompleteMatch complete)
    • This is the obvious implementation to write, but I find it quite difficult to think about.

      Doesn't this logic amount to saying "the COMPLETE pragma {-# COMPLETE P, Q, R #-} depends on P, Q and R, so if P, Q or R change then the COMPLETE pragma needs to be recompiled"? That is not what we want, what we want is "anything that mentions P, Q or R also depends on this COMPLETE pragma".

      The tests are passing, so what you wrote is probably correct, but I don't understand it.

    • Please register or sign in to reply
  • sheaf
    sheaf @sheaf started a thread on commit 6d0a5d00
  • 1509 1513 = emptyNameSet
    1510 1514 freeNamesDeclExtras (IfaceFamilyExtras _ insts _)
    1511 1515 = mkNameSet insts
    1516 freeNamesDeclExtras (IfacePatSynExtras _ complete)
    1517 = foldMap freeNamesIfCompleteMatch complete
  • sheaf
    sheaf @sheaf started a thread on commit 6d0a5d00
  • 1716 1733 return $ snd (mi_hash_fn iface occ `orElse`
    1717 1734 pprPanic "lookupVers1" (ppr mod <+> ppr occ))
    1718 1735
    1736 mkIfaceCompleteMap :: [IfaceCompleteMatch] -> OccEnv [IfaceCompleteMatch]
    1737 mkIfaceCompleteMap complete = mkOccEnv_C (++) $ concatMap (\m@(IfaceCompleteMatch syns _) -> [(getOccName syn, [m]) | syn <- syns] ) complete
    • Comment on lines +1736 to +1737

      This needs a comment, e.g. "construct a map from ConLike OccName to the list of all the COMPLETE pragmas it appears in".

    • Please register or sign in to reply
  • All looks very good, but I don't fully understand the logic to do with computing freeNames and how it plays into recompilation checking.

  • Please register or sign in to reply
    Loading