[Git][ghc/ghc][wip/T25654] 47 commits: Use checkTyEqRhs to make types concrete

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Fri Jan 31 13:32:48 UTC 2025



Ben Gamari pushed to branch wip/T25654 at Glasgow Haskell Compiler / GHC


Commits:
87e82e2e by sheaf at 2025-01-16T14:51:45+01:00
Use checkTyEqRhs to make types concrete

This commit refactors makeTypeConcrete to call checkTyEqRhs with
the appropriate parameters. This avoids duplicating subtle logic
in two places in the compiler.

Changes:

  1. Refactor of 'TyEqFlags'. Now 'TyEqFlags' stores a 'TEFTask', which
     is a description of which of the following checks we want to
     perform in 'checkTyEqRhs':
        - occurs check
        - level check
        - concreteness check

     In the process, the 'AreUnifying' datatype has been removed, as it
     is no longer needed.

  2. Refactor of 'checkTyVar':
      a. Make use of the new 'TEFTask' data type to decide which checks
         to perform.
         In particular, this ensures that we perform **both** a
         concreteness check and a level check when both are required;
         previously we only did a concreteness check (that was a bug!).
      b. Recursively call 'checkTyVar' on the kind of unfilled
         metavariables. This deals with a bug in which we failed to
         uphold the invariant that the kind of a concrete type must
         itself be concrete. See test cases T23051, T23176.

  3. Re-write of 'makeTypeConcrete', which now simply calls
     'checkTyEqRhs' with appropriate 'TyEqFlags'/'TEFTask'.
     This gets rid of code duplication and risk for the two code paths
     going out-of-sync.

Fixes #25616. See also #23883.

- - - - -
5a8f35bd by ARATA Mizuki at 2025-01-17T11:17:49-05:00
x86 NCG: Use correct format for MOVD in the implementation of unpackInt64X2#

MOVD takes the input format.

Fixes #25658

- - - - -
14f8a7ec by Mateusz Goślinowski at 2025-01-17T22:49:09+00:00
Allow multiline strings in JS FFI (#25633)

- - - - -
854c2f75 by Simon Peyton Jones at 2025-01-18T02:54:08-05:00
Fix a buglet in tcSplitForAllTyVarsReqTVBindersN

The problem was that an equation in `split` had two guards (one about
visiblity and one about `n_req`). So it fell thorugh if /either/
was False.  But the next equation then assumed an invisible binder.

Simple bug, easily fixed.  Fixes #25661.

- - - - -
264a1186 by sheaf at 2025-01-18T10:05:56+00:00
Generalise GHC diagnostic code infrastructure

This commit generalises the infrastructure used for diagnostic codes,
allowing it to be used for other namespaces than the GHC namespace.
In particular, this enables GHCi to re-use the same infrastructure to
emit error messages.

- - - - -
bf4f5ad3 by Jade at 2025-01-18T10:05:56+00:00
Add structured errors to GHCi (#23338)

This patch creates the 'GhciCommandErrorMessage' data type which
implents the 'Diagnostic' class and also provides error code for these
error conditions.

- - - - -
b6f54188 by Ben Gamari at 2025-01-18T12:38:46-05:00
Revert "Division by constants optimization"

This appears to be responsible for the regression described in #25653.

This reverts commit daff1e30219d136977c71f42e82ccc58c9013cfb.

- - - - -
0fd90de8 by Ben Gamari at 2025-01-18T12:38:46-05:00
testsuite: Introduce div2 test

This is a useful test from !8392 which is worth keeping around.

- - - - -
32680979 by Ben Gamari at 2025-01-18T12:38:46-05:00
testsuite: Test shift correctness in mul2 test

- - - - -
163aa50a by Ben Gamari at 2025-01-18T12:38:46-05:00
testsuite: Add regression test for #25653

- - - - -
44778963 by Matthew Pickering at 2025-01-20T11:23:08+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.

Fixes #25634

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

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

- - - - -
b3c0acfc by Cheng Shao at 2025-01-20T11:53:10-05:00
hie: fix hie.yaml to use default hie-bios script

!13778 accidentally changed hie.yaml to use hie-bios.bat as the
default hie-bios script, which completely breaks hie support on
non-Windows platforms. This patch reverts that change.

- - - - -
595013d4 by Ben Gamari at 2025-01-21T09:57:23-05:00
compiler: Fix CPP guards around ghc_unique_counter64

The `ghc_unique_counter64` symbol was introduced in the RTS in the
64-bit unique refactor (!10568) which has been backported to %9.6.7 and
%9.8.4. Update the CPP to reflect this.

Fixes #25576.

- - - - -
09ee3247 by Ryan Scott at 2025-01-21T09:58:00-05:00
Fix :info pretty-printing of UNPACKed fields

This patch:

* Ensures that we do not pretty-print a field like `foo :: {-# UNPACK #-} !Int`
  as `foo :: ! {-# UNPACK -#} Int` (as we were doing before) when running the
  `:info` command.
* Prevents coercions that arise from `UNPACK`ed fields (e.g., such as when one
  unpacks a newtype) from being printed in `:info` output unless `-dppr-debug`
  is enabled.

Fixes #25651.

- - - - -
6b7ea592 by Rodrigo Mesquita at 2025-01-21T16:10:35-05:00
driver: Store the HomePackageTable in a mutable reference

This commit refactors the HomePackageTable and HomeUnitGraph:

(1) It fixes a quadratic-in-the-number-of-modules space leak in upsweep (#25511)

(2) And it reworks these structures into their own modules to simplify
    the driver. The refactor is driven by the introduction of IO in the HPT
    interface, but is a bit more aggressive in simplifying the
    interfaces to enforce correct usage (ie to avoid performance
    pitfalls).

Specifically:

- The `HomeUnitGraph` (HUG) is now in `GHC.Unit.Home.Graph`
- The `HomePackageTable` (HPT) is now in `GHC.Unit.Home.PackageTable`
    - The HPT now stores an `IORef` with the table of loaded home package modules.
    - The interface to the HPT now requires IO
    - The interface now enforces that the HPT is a datastructure that
      only grows
    - This is not enforced in the interface, but, clients of the HPT
      should never care about there being more or less entries in the
      HPT when these additional entries are not relevant to their result.
    - The exception to the invariant that the HPT is monotonically
      increasing is `restrictHpt`, a function which is called at a
      "barrier point" (during which there are no other threads
      inspecting or inserting in the HPT). The invariant can be
      temporarily broken at this point (currently, after upsweep).
      This is safe because a single thread holds control over the
      structure (thus the invariant being broken is never observed).

The hug_var and associated structures in the driver, which aimed to
improve memory usage in the driver by updating in place a HUG during
upsweep, are no longer required as the HPT entries in the HUG are now
themselves mutable by construction. This was previously explained in
Note [ModuleNameSet, efficiency and space leaks], which is no longer
relevant and was deleted.

Fixes #25511

Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>

-------------------------
Metric Decrease:
    MultiComponentModulesRecomp
    MultiLayerModulesRecomp
-------------------------

- - - - -
f983a00f by Jens Petersen at 2025-01-21T16:11:12-05:00
hp2ps/Utilities.c: add extern parameter types for malloc and realloc for C23

Fix build with gcc-15 which defaults to C23 standard (-std=gnu23)
Fixes #25662
```
utils/hp2ps/Utilities.c:6:14: error:
     warning: conflicting types for built-in function ‘malloc’; expected ‘void *(long unsigned int)’ [-Wbuiltin-declaration-mismatch]
        6 | extern void* malloc();
          |              ^~~~~~
  |
6 | extern void* malloc();
  |              ^
utils/hp2ps/Utilities.c:5:1: error:
     note: ‘malloc’ is declared in header ‘<stdlib.h>’
        4 | #include "Error.h"
      +++ |+#include <stdlib.h>
        5 | 
  |
5 | 
  | ^
utils/hp2ps/Utilities.c: In function ‘xmalloc’:
utils/hp2ps/Utilities.c:80:17: error:
     error: too many arguments to function ‘malloc’; expected 0, have 1
       80 |     r = (void*) malloc(n);
          |                 ^~~~~~ ~
   |
80 |     r = (void*) malloc(n);
   |                 ^
utils/hp2ps/Utilities.c:6:14: error:
     note: declared here
        6 | extern void* malloc();
          |              ^~~~~~
  |
6 | extern void* malloc();
  |              ^
utils/hp2ps/Utilities.c: In function ‘xrealloc’:
utils/hp2ps/Utilities.c:92:18: error:
     warning: conflicting types for built-in function ‘realloc’; expected ‘void *(void *, long unsigned int)’ [-Wbuiltin-declaration-mismatch]
       92 |     extern void *realloc();
          |                  ^~~~~~~
   |
92 |     extern void *realloc();
   |                  ^
utils/hp2ps/Utilities.c:92:18: error:
     note: ‘realloc’ is declared in header ‘<stdlib.h>’
   |
92 |     extern void *realloc();
   |                  ^
utils/hp2ps/Utilities.c:94:9: error:
     error: too many arguments to function ‘realloc’; expected 0, have 2
       94 |     r = realloc(p, n);
          |         ^~~~~~~ ~
   |
94 |     r = realloc(p, n);
   |         ^
utils/hp2ps/Utilities.c:92:18: error:
     note: declared here
       92 |     extern void *realloc();
          |                  ^~~~~~~
   |
92 |     extern void *realloc();
   |                  ^
```
- - - - -
51e3ec83 by Vladislav Zavialov at 2025-01-22T20:41:32+03:00
Rework built-in and punned names (#25174, #25179, #25180, #25182)

This patch rewrites part of the logic for dealing with built-in and
punned names, making it more principled and fixing a few bugs.

* Kill off filterCTuple. Its purpose was to improve pretty-printing of
  constraint tuples, and the appropriate place for this is namePun_maybe.

* Remove unitTyCon, unboxedUnitTyCon, and soloTyCon from wiredInTyCons.
  Their inclusion in the list was a workaround for shoddy logic in
  lookupOrigNameCache. Now we treat tuples of all arities uniformly.

* In isBuiltInOcc_maybe, only match on actual built-in syntax, e.g. "FUN"
  shouldn't be there (#25174). Also take ListTuplePuns into account (#25179).

* When matching OccNames, use the ShortByteString directly to avoid
  potentially costly conversions to ByteString and String.

* Introduce isInfiniteFamilyOrigName_maybe, a purpose-built helper for
  looking up tuples/sums in the OrigNameCache. This clears up the previously
  convoluted relation between the orig name cache and built-in syntax.

* Reuse isKnownOrigName_maybe to eliminate the need for isPunOcc_maybe.

* Classify MkSolo and MkSolo# as UserSyntax, thus fixing whole-module
  reexports (#25182).

* Teach valid-hole-fits about tuples, unboxed tuples, and unboxed sums,
  up to a certain arity (#25180).

* Drop the unnecessary special case for unary constraint tuples in the
  type checker (finish_tuple). It was a workaround for the lack of CSolo.

* Update Notes and other comments, add tests.

- - - - -
85c60aea by Teo Camarasu at 2025-01-23T18:06:21-05:00
doc: Add documentation for -XDoAndIfThenElse

Resolves #18631

Co-authored-by: Richard Eisenberg <rae at cs.brynmawr.edu>

- - - - -
4495e48f by Brandon Chinn at 2025-01-24T11:54:24-05:00
Break out GHC.Parser.Lexer.Interface

- - - - -
4f8fc11e by Brandon Chinn at 2025-01-24T11:54:24-05:00
Fix lexing comments in multiline strings (#25609)

Metric Decrease:
    MultiLayerModulesRecomp
    parsing001

- - - - -
e7ab778f by Matthew Pickering at 2025-01-24T11:55:01-05:00
testsuite: Pass TEST_HC_OPTS to many more tests

This passes `-dno-debug-output` to the test and `-dlint.

- - - - -
c3593101 by Sylvain Henry at 2025-01-24T23:12:20-05:00
Merge ghc-prim's modules into ghc-internal (#24453)

ghc-internal becomes the only wired-in package exposing primitives.

There are some minor GHC allocation regressions, but they barely cross
the thresholds and only with the wasm backend. They're likely due to
longer symbols (ghc-internal vs ghc-prim, GHC.Internal.X vs GHC.X).

Metric Increase:
    T13035
    T1969
    T4801
    T9961

- - - - -
70f7741a by Jens Petersen at 2025-01-24T23:12:58-05:00
hp2ps/Utilities.c: add extern parameter types for malloc and realloc for C23

use portable C types!

- - - - -
a1d92378 by Brandon Chinn at 2025-01-25T15:11:54-08:00
Fix for alex-3.5.2.0 (#25623)

This INLINE pragma for alexScanUser was added in 9.12, but then I
ported the change to alex in 3.5.2.0
(https://github.com/haskell/alex/pull/262).

I didn't realize that GHC errors on duplicate INLINE pragmas, so
this ended up being a breaking change.

This change should be backported into 9.12

- - - - -
62760367 by ARATA Mizuki at 2025-01-27T16:23:06-05:00
x86 NCG: Make MOVD's output format explicit

The old design led to inference of a wrong format,
losing upper bits of a vector register.

Fixes #25659

Co-authored-by: sheaf <sam.derbyshire at gmail.com>

- - - - -
f19ab490 by Simon Hengel at 2025-01-27T16:23:45-05:00
doc: Correct JSON schema for `-fdiagnostics-as-json` (fixes #25393)

- - - - -
e16eae65 by Cheng Shao at 2025-01-27T21:41:39+00:00
hadrian: fix bootstrap with 9.12.1

This patch bumps hadrian index-state to fix bootstrap with 9.12.1.

- - - - -
8071bad8 by Jeffrey Young at 2025-01-28T21:45:32-05:00
base: add SrcLoc changes to changelog, 4.21.0.0

I accidentally dropped this in !13381

- closes #25614

See:

- ea4587794b9e3a098f9c02bd6cea2294af2539ce  (the 13381 commit)
- Issue #25614

- - - - -
9dcc7e28 by M Farkas-Dyck at 2025-01-29T02:27:48-05:00
Rename `cloneBndrs` and such — now all the monadic ones have an `M` suffix.

We now have `cloneBndrs` and `cloneRecIdBndrs` which take a `UniqSupply` argument, and `cloneBndrsM` and `cloneRecIdBndrsM` which rather have a `MonadUnique` constraint.

- - - - -
643dd3d8 by Matthew Farkas-Dyck at 2025-01-29T02:27:48-05:00
Use `Infinite` in unique generation, and clean up some other partial uni patterns as well.

Also drop the losing `instance MonadFail UniqSM`.

We redefine `getUniquesM` in terms of `Infinite` rather than `[]`, and define another method `getUniqueListM` for the use sites where we actually want a `[]`.
Thus, at many sites, we can avoid the partiality of the empty list case.

We also define `withUniques`, `withUniquesM`, and `withUniquesM'`, which traverse an arbitrary `Traversable` structure and introduce a `Unique` for each element.
This allows us to redefine various functions to operate on more appropriate types than `[]` and avoid further partiality (in the form of incomplete-uni-patterns).

- - - - -
dd0acc3c by M Farkas-Dyck at 2025-01-29T02:27:48-05:00
Use `Infinite` in `GHC.Tc.Deriv.Functor`.

Make the list of variables to use in generated code `Infinite`, to avoid panicking on the (now impossible) empty list case.

- - - - -
4e9adedf by M Farkas-Dyck at 2025-01-29T02:27:48-05:00
Use `Infinite` in `GHC.Runtime.Debugger`.

Make the list of available names `Infinite`, to avoid panicking on the (now impossible) empty list case.

- - - - -
bed812b7 by M Farkas-Dyck at 2025-01-29T02:27:48-05:00
Avoid incomplete-uni-patterns in `GHC.Cmm.DebugBlock`.

We do so by changing the type of `BlockContext` to statically (in GHC) exclude the possibility of Cmm statics, and using `NonEmpty` lists of `BlockContext`s in `cmmDebugGen`.

- - - - -
27587df3 by M Farkas-Dyck at 2025-01-29T02:27:48-05:00
Avoid incomplete-uni-patterns in `GHC.Types.Literal`.

We do so by introducing `mkLitNumberWrap'` whose ultimate codomain is `Integer` rather than `Literal`, and then use that rather than `mkLitNumberWrap` where we just need the number rather than the `Literal`.

- - - - -
138de0ff by M Farkas-Dyck at 2025-01-29T02:27:48-05:00
Avoid incomplete-uni-patterns in `GHC.CmmToAsm.X86.CodeGen`.

- Match the vector element list only once in `shuffleInstructions`.
- Define `isSuitableFloatingPointLit_maybe` which returns `Just` the width if the lit is indeed suitable.

- - - - -
d8cb3d36 by M Farkas-Dyck at 2025-01-29T02:27:48-05:00
Clean up more incomplete uni patterns.

At some sites, we merely panic if the `[]` or `Maybe` is empty when we convert to `NonEmpty` or `Identity`, but at least now we make it explicit.

At other sites, we are able to use more precise types and avoid the partiality altogether. To do so, we redefine various functions to operate over `Traversable` arguments, so we can use the appropriate shape where known.

- - - - -
f251bd22 by M Farkas-Dyck at 2025-01-29T02:27:48-05:00
Outline `expectJustPanic`.

- - - - -
a963a1a5 by Marc Scholten at 2025-01-29T02:28:35-05:00
base: Introduce Data.Enum.enumerate (CLC #306)

https://github.com/haskell/core-libraries-committee/issues/306

- - - - -
944712da by Ben Gamari at 2025-01-29T02:29:13-05:00
base: Update description of locking behavior
- - - - -
85abc69c by Ben Gamari at 2025-01-29T02:29:51-05:00
base: Fix @since annotation of Data.Bounded

Fixes #25615.

- - - - -
2ca41c62 by Ben Gamari at 2025-01-29T02:30:29-05:00
StgToByteCode: Fix overly-broad handling of Addr# literals

Previously we assumed that all unlifted types were `Addr#` but this
isn't true. As noted in #25638, unlifted nullary data constructor
workers can also appear at the top-level and are obviously not of type
`Addr#`.

Note that there is more work to be done to properly handle unlifted data
constructors (especially nullary; see #25636). However, this is a small
step in the right direction.

Closes #25641.

- - - - -
ec26c54d by Ben Gamari at 2025-01-29T02:30:29-05:00
StgToByteCode: Assert that PUSH_G'd values are lifted

We currently do not support top-level unlifted data constructor applications,
therefore this is a safe assertion.

Pointed out by @sheaf.
- - - - -
8847125f by Ben Gamari at 2025-01-29T02:31:07-05:00
gitlab-ci: Run test-primops testsuite in ~"full-ci" pipeline

Closes #25654.

- - - - -
bf8c7d6e by Matthew Pickering at 2025-01-29T02:31:44-05:00
bytecode: Do not generate `SLIDE x 0` instructions

SLIDE x 0 is a no-op as it means to shift x elements of the stack by no
spaces. In the interpreter, this results in a loop which copies an array
element into the same place.

I have instrumented GHCi to count how many of these instructions are interpreted.
The workload was `ghc` compiling two simple modules.

Total no-op slides: 7793476
Total slides: 11413289
Percentage useless (slides): 68%
Percentage uselss of total instructions: 9%

- - - - -
7bfc93a7 by Zubin Duggal at 2025-01-29T21:41:17-05:00
hackage-doc-tarball: Allow ghc-boot-th to be uploaded to hackage

It can't refer to files outside its source directory, so patch that part out.
This is OK because those files are only used while bootstrapping.

Also add ghci to the list of packages to be uploaded

Fixes #25687

- - - - -
704eeb02 by Roman S at 2025-01-29T21:42:05-05:00
Fix Control.Arrow (***) diagram (fixes #25698)
- - - - -
59ef1000 by Ben Gamari at 2025-01-31T08:30:25-05:00
gitlab-ci: Don't use .full-ci to run test-primops

test-primops depends upon the existence of validate jobs, yet these do
not exist in the context of nightly jobs, which .full-ci includes.

- - - - -


30 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/rel_eng/upload_ghc_libs.py
- compiler/GHC.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/Uniques.hs
- compiler/GHC/ByteCode/Linker.hs
- compiler/GHC/Cmm/Config.hs
- compiler/GHC/Cmm/DebugBlock.hs
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/Cmm/Opt.hs
- compiler/GHC/Cmm/Pipeline.hs
- compiler/GHC/Cmm/Sink.hs
- compiler/GHC/Cmm/ThreadSanitizer.hs
- compiler/GHC/Cmm/Utils.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/CFG.hs
- compiler/GHC/CmmToAsm/PPC/Instr.hs
- compiler/GHC/CmmToAsm/Reg/Graph/Stats.hs
- compiler/GHC/CmmToAsm/Reg/Linear.hs
- compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs
- compiler/GHC/CmmToAsm/Reg/Liveness.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Opt/Pipeline.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9dc07fcfc1aa422349693e22d63f5343d9481513...59ef1000634b388cc1f677fb53ba72cb3ac137dc

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9dc07fcfc1aa422349693e22d63f5343d9481513...59ef1000634b388cc1f677fb53ba72cb3ac137dc
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/20250131/7ccfb836/attachment-0001.html>


More information about the ghc-commits mailing list