[Git][ghc/ghc][wip/mpickering/get-link-deps] driver: Store an ExternalModuleGraph in the EPS

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Mon Jan 6 16:34:58 UTC 2025



Matthew Pickering pushed to branch wip/mpickering/get-link-deps at Glasgow Haskell Compiler / GHC


Commits:
c79ea412 by Matthew Pickering at 2025-01-06T16:34:46+00:00
driver: Store an ExternalModuleGraph in the EPS

We now store an ExternalModuleGraph in the EPS. When an new interface is
loaded, the module graph is extended with a node for the loaded
interface. The result is a partial module graph. If you want to run
a transitive closure query on the graph you must first force the
transitive closure to be loaded by using `loadExternalGraphBelow`.

The primary advantage (for now) is that the transitive dependency
calculation does not have to be repeated in getLinkDeps. If your module
had many dependencies and many splices, performing this calculation at
every splice site took a significant amount of time.

We might also want to use this module graph in future for considering
questions such as reachability of rules or accessibilty of instance
imported by levelled imported.

This patch removes another place in the compiler where transitive
dependency is calculated in an ad-hoc manner. In general, the transitive
dependency calculation should be cached and computed using a ModuleGraph
abstraction.

The transitive dependency query required by getLinkDeps operates on a
graph without hs-boot nodes. If a linkable from a module in a loop is
needed, then all modules in the loop are necessary to be available to
execute that module. Therefore there is a query in `ModuleGraph` and
`ExternalModuleGraph` which allows a transitive closure query to be
performed on a graph without loops.

-------------------------
Metric Decrease:
    MultiLayerModulesTH_Make
    MultiLayerModulesTH_OneShot
Metric Increase:
    mhu-perf
-------------------------

Co-authored-by: Rodrigo Mesquita <rodrigo.m.mesquita at gmail.com>

- - - - -


30 changed files:

- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Errors/Ppr.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/MakeFile.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Linker/Deps.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Unit/External.hs
- + compiler/GHC/Unit/Module/External/Graph.hs
- compiler/GHC/Unit/Module/Graph.hs
- + compiler/GHC/Unit/Module/ModNodeKey.hs
- compiler/ghc.cabal.in
- testsuite/tests/backpack/reexport/bkpreex02.stderr
- testsuite/tests/backpack/reexport/bkpreex03.stdout
- testsuite/tests/backpack/should_compile/bkp09.stderr
- testsuite/tests/backpack/should_compile/bkp14.stderr
- testsuite/tests/backpack/should_compile/bkp15.stderr
- testsuite/tests/backpack/should_compile/bkp31.stderr
- testsuite/tests/backpack/should_compile/bkp32.stderr
- testsuite/tests/backpack/should_compile/bkp47.stderr
- testsuite/tests/backpack/should_compile/bkp51.stderr
- testsuite/tests/backpack/should_compile/bkp61.stderr
- testsuite/tests/backpack/should_fail/bkpfail07.stderr
- testsuite/tests/backpack/should_fail/bkpfail09.stderr
- testsuite/tests/backpack/should_fail/bkpfail12.stderr
- testsuite/tests/backpack/should_fail/bkpfail13.stderr
- testsuite/tests/backpack/should_fail/bkpfail14.stderr
- testsuite/tests/backpack/should_fail/bkpfail15.stderr
- testsuite/tests/backpack/should_fail/bkpfail21.stderr


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c79ea4127fae8fbc2f355d0480c4a528c2920ecc

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c79ea4127fae8fbc2f355d0480c4a528c2920ecc
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/20250106/f74459c9/attachment.html>


More information about the ghc-commits mailing list