[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 45 commits: WorkWrap: Unboxing unboxed tuples is not always useful (#22388)

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Nov 11 02:46:55 UTC 2022



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00
WorkWrap: Unboxing unboxed tuples is not always useful (#22388)

See Note [Unboxing through unboxed tuples].

Fixes #22388.

- - - - -
1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00
Boxity: Handle argument budget of unboxed tuples correctly (#21737)

Now Budget roughly tracks the combined width of all arguments after unarisation.
See the changes to `Note [Worker argument budgets]`.

Fixes #21737.

- - - - -
986da50b by Cheng Shao at 2022-11-10T21:46:47-05:00
autoconf: check getpid getuid raise

This patch adds checks for getpid, getuid and raise in autoconf. These
functions are absent in wasm32-wasi and thus needs to be checked.

- - - - -
5977293a by Cheng Shao at 2022-11-10T21:46:47-05:00
hadrian: add -Wwarn only for cross-compiling unix

- - - - -
28c54145 by Cheng Shao at 2022-11-10T21:46:47-05:00
hadrian: add targetSupportsThreadedRts flag

This patch adds a targetSupportsThreadedRts flag to indicate whether
the target supports the threaded rts at all, different from existing
targetSupportsSMP that checks whether -N is supported by the RTS. All
existing flavours have also been updated accordingly to respect this
flags.

Some targets (e.g. wasm32-wasi) does not support the threaded rts,
therefore this flag is needed for the default flavours to work. It
makes more sense to have proper autoconf logic to check for threading
support, but for the time being, we just set the flag to False iff the
target is wasm32.

- - - - -
c9b66591 by Cheng Shao at 2022-11-10T21:46:47-05:00
Fix Cmm symbol kind

- - - - -
11334652 by Norman Ramsey at 2022-11-10T21:46:47-05:00
add the two key graph modules from Martin Erwig's FGL

Martin Erwig's FGL (Functional Graph Library) provides an "inductive"
representation of graphs.  A general graph has labeled nodes and
labeled edges.  The key operation on a graph is to decompose it by
removing one node, together with the edges that connect the node to
the rest of the graph.  There is also an inverse composition
operation.

The decomposition and composition operations make this representation
of graphs exceptionally well suited to implement graph algorithms in
which the graph is continually changing, as alluded to in #21259.

This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the
interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides
an implementation.  Both modules are taken from `fgl-5.7.0.3` on
Hackage, with these changes:

  - Copyright and license text have been copied into the files
    themselves, not stored separately.

  - Some calls to `error` have been replaced with calls to `panic`.

  - Conditional-compilation support for older versions of GHC,
    `containers`, and `base` has been removed.

- - - - -
13723410 by Norman Ramsey at 2022-11-10T21:46:47-05:00
add new modules for reducibility and WebAssembly translation

- - - - -
e2b90391 by Cheng Shao at 2022-11-10T21:46:47-05:00
Add support for the wasm32-wasi target tuple

This patch adds the wasm32-wasi tuple support to various places in the
tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen
logic will come in subsequent commits.

- - - - -
420dba20 by Cheng Shao at 2022-11-10T21:46:47-05:00
deriveConstants: parse .ll output for wasm32 due to broken nm

This patch makes deriveConstants emit and parse an .ll file when
targeting wasm. It's a necessary workaround for broken llvm-nm on
wasm, which isn't capable of reporting correct constant values when
parsing an object.

- - - - -
5987e0e1 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking

Unlike other targets, wasm requires the function signature of the call
site and callee to strictly match. So in Cmm, when we call a C
function that actually returns a value, we need to add an _unused
local variable to receive it, otherwise type error awaits.

An even bigger problem is calling variadic functions like barf() and
such. Cmm doesn't support CAPI calling convention yet, so calls to
variadic functions just happen to work in some cases with some
target's ABI. But again, it doesn't work with wasm. Fortunately, the
wasm C ABI lowers varargs to a stack pointer argument, and it can be
passed NULL when no other arguments are expected to be passed. So we
also add the additional unused NULL arguments to those functions, so
to fix wasm, while not affecting behavior on other targets.

- - - - -
1b27f82f by Cheng Shao at 2022-11-10T21:46:47-05:00
testsuite: correct sleep() signature in T5611

In libc, sleep() returns an integer. The ccall type signature should
match the libc definition, otherwise it causes linker error on wasm.

- - - - -
7c803a9b by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: prefer ffi_type_void over FFI_TYPE_VOID

This patch uses ffi_type_void instead of FFI_TYPE_VOID in the
interpreter code, since the FFI_TYPE_* macros are not available in
libffi-wasm32 yet. The libffi public documentation also only mentions
the lower-case ffi_type_* symbols, so we should prefer the lower-case
API here.

- - - - -
37faf4b0 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: don't define RTS_USER_SIGNALS when signal.h is not present

In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related
logic is guarded with RTS_USER_SIGNALS. This patch extends the range
of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff
signal.h is actually detected by autoconf. This is required for
wasm32-wasi to work, which lacks signals.

- - - - -
299b3538 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: use HAVE_GETPID to guard subprocess related logic

We've previously added detection of getpid() in autoconf. This patch
uses HAVE_GETPID to guard some subprocess related logic in the RTS.
This is required for certain targets like wasm32-wasi, where there
isn't a process model at all.

- - - - -
017c0675 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined

This patch adds the missing THREADED_RTS CPP guard to mutex logic in
IPE.c.

- - - - -
be83d260 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: genericRaise: use exit() instead when not HAVE_RAISE

We check existence of raise() in autoconf, and here, if not
HAVE_RAISE, we should use exit() instead in genericRaise.

- - - - -
1e1a9a94 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: checkSuid: don't do it when not HAVE_GETUID

When getuid() is not present, don't do checkSuid since it doesn't make
sense anyway on that target.

- - - - -
7517399d by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: wasm32 placeholder linker

This patch adds minimal placeholder linker logic for wasm32, just
enough to unblock compiling rts on wasm32. RTS linker functionality is
not properly implemented yet for wasm32.

- - - - -
e75578fa by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: RtsStartup: chdir to PWD on wasm32

This patch adds a wasm32-specific behavior to RtsStartup logic. When
the PWD environment variable is present, we chdir() to it first.

The point is to workaround an issue in wasi-libc: it's currently not
possible to specify the initial working directory, it always defaults
to / (in the virtual filesystem mapped from some host directory). For
some use cases this is sufficient, but there are some other cases
(e.g. in the testsuite) where the program needs to access files
outside.

- - - - -
bbd783a6 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: no timer for wasm32

Due to the lack of threads, on wasm32 there can't be a background
timer that periodically resets the context switch flag. This patch
disables timer for wasm32, and also makes the scheduler default to -C0
on wasm32 to avoid starving threads.

- - - - -
785bb58c by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32

The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32.

- - - - -
53d8e303 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32

On wasm32 there isn't a process model at all, so no
FORKPROCESS_PRIMOP_SUPPORTED.

- - - - -
94775ec3 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32

libffi-wasm32 only supports non-standard libffi closure api via
ffi_alloc_prep_closure(). This patch implements
ffi_alloc_prep_closure() via standard libffi closure api on other
targets, and uses it to implement adjustor functionality.

- - - - -
383ab645 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: don't return memory to OS on wasm32

This patch makes the storage manager not return any memory on wasm32.
The detailed reason is described in Note [Megablock allocator on
wasm].

- - - - -
bd65aa20 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: make flushExec a no-op on wasm32

This patch makes flushExec a no-op on wasm32, since there's no such
thing as executable memory on wasm32 in the first place.

- - - - -
dad65350 by Cheng Shao at 2022-11-10T21:46:47-05:00
rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32

This patch prevents resetTerminalSettings and freeThreadingResources
to be called on wasm32, since there is no TTY or threading on wasm32
at all.

- - - - -
00b51fb4 by Cheng Shao at 2022-11-10T21:46:48-05:00
rts: OSThreads.h: stub types for wasm32

This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey
types for wasm32, just enough to unblock compiling RTS. Any
threading-related functionality has been patched to be disabled on
wasm32.

- - - - -
0b656cf2 by Cheng Shao at 2022-11-10T21:46:48-05:00
Add register mapping for wasm32

This patch adds register mapping logic for wasm32. See Note [Register
mapping on WebAssembly] in wasm32 NCG for more description.

- - - - -
6ff6bd89 by Cheng Shao at 2022-11-10T21:46:48-05:00
rts: wasm32 specific logic

This patch adds the rest of wasm32 specific logic in rts.

- - - - -
aac4301a by Cheng Shao at 2022-11-10T21:46:48-05:00
base: fall back to using monotonic clock to emulate cputime on wasm32

On wasm32, we have to fall back to using monotonic clock to emulate
cputime, since there's no native support for cputime as a clock id.

- - - - -
386792be by Cheng Shao at 2022-11-10T21:46:48-05:00
base: more autoconf checks for wasm32

This patch adds more autoconf checks to base, since those functions
and headers may exist on other POSIX systems but don't exist on
wasm32.

- - - - -
215b2c84 by Cheng Shao at 2022-11-10T21:46:48-05:00
base: avoid using unsupported posix functionality on wasm32

This base patch avoids using unsupported posix functionality on
wasm32.

- - - - -
9ed49e35 by Cheng Shao at 2022-11-10T21:46:48-05:00
autoconf: set CrossCompiling=YES in cross bindist configure

This patch fixes the bindist autoconf logic to properly set
CrossCompiling=YES when it's a cross GHC bindist.

- - - - -
cda59b64 by Cheng Shao at 2022-11-10T21:46:48-05:00
compiler: add util functions for UniqFM and UniqMap

This patch adds addToUFM_L (backed by insertLookupWithKey),
addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util
functions are used by the wasm32 NCG.

- - - - -
83373ef0 by Cheng Shao at 2022-11-10T21:46:48-05:00
driver: avoid -Wl,--no-as-needed for wasm32

The driver used to pass -Wl,--no-as-needed for LLD linking. This is
actually only supported for ELF targets, and must be avoided when
linking for wasm32.

- - - - -
298e3d22 by Cheng Shao at 2022-11-10T21:46:48-05:00
compiler: allow big arith for wasm32

This patch enables Cmm big arithmetic on wasm32, since 64-bit
arithmetic can be efficiently lowered to wasm32 opcodes.

- - - - -
da91d54f by Cheng Shao at 2022-11-10T21:46:48-05:00
driver: pass -Wa,--no-type-check for wasm32 when runAsPhase

This patch passes -Wa,--no-type-check for wasm32 when compiling
assembly. See the added note for more detailed explanation.

- - - - -
5892c6f2 by Cheng Shao at 2022-11-10T21:46:48-05:00
compiler: enforce cmm switch planning for wasm32

This patch forcibly enable Cmm switch planning for wasm32, since
otherwise the switch tables we generate may exceed the br_table
maximum allowed size.

- - - - -
876387b5 by Cheng Shao at 2022-11-10T21:46:48-05:00
compiler: annotate CmmFileEmbed with blob length

This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG
needs to know the precise size of each data segment.

- - - - -
0fa624fd by Cheng Shao at 2022-11-10T21:46:48-05:00
compiler: wasm32 NCG

This patch adds the wasm32 NCG.

- - - - -
bc6f7bcc by Cheng Shao at 2022-11-10T21:46:48-05:00
ci: add wasm32-wasi release bindist job

- - - - -
205c5ce4 by Cheng Shao at 2022-11-10T21:46:48-05:00
ci: add a stronger test for cross bindists

This commit adds a simple GHC API program that parses and reprints the
original hello world program used for basic testing of cross bindists.
Before there's full cross-compilation support in the test suite
driver, this provides better coverage than the original test.

- - - - -
884b1a03 by Cheng Shao at 2022-11-10T21:46:48-05:00
CODEOWNERS: add wasm-specific maintainers

- - - - -
573f92d9 by Zubin Duggal at 2022-11-10T21:46:48-05:00
Clarify that LLVM upper bound is non-inclusive during configure (#22411)

- - - - -


25 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- + .gitlab/hello.hs
- CODEOWNERS
- compiler/CodeGen.Platform.h
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/CLabel.hs
- + compiler/GHC/Cmm/Reducibility.hs
- compiler/GHC/Cmm/Utils.hs
- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
- compiler/GHC/CmmToAsm/PPC/Ppr.hs
- compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs
- compiler/GHC/CmmToAsm/Reg/Linear.hs
- compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs
- compiler/GHC/CmmToAsm/Reg/Target.hs
- + compiler/GHC/CmmToAsm/Wasm.hs
- + compiler/GHC/CmmToAsm/Wasm/Asm.hs
- + compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
- + compiler/GHC/CmmToAsm/Wasm/Types.hs
- + compiler/GHC/CmmToAsm/Wasm/Utils.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs
- + compiler/GHC/Data/Graph/Collapse.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5252c7f8ad22433c9b10d11907772c582e40f227...573f92d92b3ee7928c2e5fd46efc3e723be9bf64

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5252c7f8ad22433c9b10d11907772c582e40f227...573f92d92b3ee7928c2e5fd46efc3e723be9bf64
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/20221110/45c28fc3/attachment-0001.html>


More information about the ghc-commits mailing list