[Git][ghc/ghc][wip/az/ghc-cpp] 54 commits: Fix for alex-3.5.2.0 (#25623)

Alan Zimmerman (@alanz) gitlab at gitlab.haskell.org
Sun Feb 2 23:17:11 UTC 2025



Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC


Commits:
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)
- - - - -
269fdfdd by Alan Zimmerman at 2025-02-01T10:49:09+00:00
GHC-CPP: first rough proof of concept

Processes

     #define FOO
     #ifdef FOO
     x = 1
     #endif

Into

    [ITcppIgnored [L loc ITcppDefine]
    ,ITcppIgnored [L loc ITcppIfdef]
    ,ITvarid "x"
    ,ITequal
    ,ITinteger (IL {il_text = SourceText "1", il_neg = False, il_value = 1})
    ,ITcppIgnored [L loc ITcppEndif]
    ,ITeof]

In time, ITcppIgnored will be pushed into a comment

- - - - -
4467d44b by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Tidy up before re-visiting the continuation mechanic

- - - - -
95cbc2d7 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Switch preprocessor to continuation passing style

Proof of concept, needs tidying up

- - - - -
54c278db by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Small cleanup

- - - - -
0883493f by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Get rid of some cruft

- - - - -
64bd6a0c by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Starting to integrate.

Need to get the pragma recognised and set

- - - - -
81134858 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Make cppTokens extend to end of line, and process CPP comments

- - - - -
10ef3eff by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Remove unused ITcppDefined

- - - - -
baa2b797 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Allow spaces between # and keyword for preprocessor directive

- - - - -
6c8846b5 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Process CPP continuation lines

They are emited as separate ITcppContinue tokens.
Perhaps the processing should be more like a comment, and keep on
going to the end.
BUT, the last line needs to be slurped as a whole.

- - - - -
d8ea6bf7 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Accumulate CPP continuations, process when ready

Can be simplified further, we only need one CPP token

- - - - -
2508452a by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Simplify Lexer interface. Only ITcpp

We transfer directive lines through it, then parse them from scratch
in the preprocessor.

- - - - -
560ed5ec by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Deal with directive on last line, with no trailing \n

- - - - -
2751d2ed by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Start parsing and processing the directives

- - - - -
2c75b2cd by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Prepare for processing include files

- - - - -
6bbc72e2 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Move PpState into PreProcess

And initParserState, initPragState too

- - - - -
8710ea96 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Process nested include files

Also move PpState out of Lexer.x, so it is easy to evolve it in a ghci
session, loading utils/check-cpp/Main.hs

- - - - -
c4726bea by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Split into separate files

- - - - -
4afbdcd3 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Starting on expression parser.

But it hangs. Time for Text.Parsec.Expr

- - - - -
a2786148 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Start integrating the ghc-cpp work

>From https://github.com/alanz/ghc-cpp

- - - - -
f30904bd by Alan Zimmerman at 2025-02-01T10:49:09+00:00
WIP

- - - - -
ba29a952 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Fixup after rebase

- - - - -
5cdac204 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
WIP

- - - - -
5e209d54 by Alan Zimmerman at 2025-02-01T10:49:09+00:00
Fixup after rebase, including all tests pass

- - - - -
4afec6ec by Alan Zimmerman at 2025-02-01T11:54:53+00:00
Change pragma usage to GHC_CPP from GhcCPP

- - - - -
baad4fd2 by Alan Zimmerman at 2025-02-02T11:27:49+00:00
Some comments

- - - - -
2507ac9e by Alan Zimmerman at 2025-02-02T11:28:21+00:00
Reformat

- - - - -
c8f167a9 by Alan Zimmerman at 2025-02-02T11:49:33+00:00
Delete unused file

- - - - -
53a647e0 by Alan Zimmerman at 2025-02-02T11:52:06+00:00
Rename module Parse to ParsePP

- - - - -
cb4f357a by Alan Zimmerman at 2025-02-02T12:13:02+00:00
Clarify naming in the parser

- - - - -
d91c19a3 by Alan Zimmerman at 2025-02-02T23:16:23+00:00
WIP. Switching to alex/happy to be able to work in-tree

Since Parsec is not available

- - - - -


30 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/rel_eng/upload_ghc_libs.py
- compiler/GHC.hs
- compiler/GHC/Cmm/DebugBlock.hs
- compiler/GHC/Cmm/Lexer.x
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Cmm/Parser/Monad.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/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b4134b73432211cb9a8a306cd318765b532bcdac...d91c19a39a9fd5fe4a2f2800d37ca6232f4e0db5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b4134b73432211cb9a8a306cd318765b532bcdac...d91c19a39a9fd5fe4a2f2800d37ca6232f4e0db5
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/20250202/1010a6f2/attachment-0001.html>


More information about the ghc-commits mailing list