Commit Graph

27019 Commits

Author SHA1 Message Date
Jakub Konka
0de5dd2ef1 elf: misc fixes 2023-11-09 10:32:39 +01:00
Linus Groh
e72049bc61 std.math: Add isPositiveZero() and isNegativeZero() 2023-11-09 00:55:43 -07:00
Andrew Kelley
b2ed2c4d4f
Merge pull request #17888 from AdamGoertz/zig-reduce
zig-reduce: Add reductions for `if` and `while`
2023-11-09 00:52:38 -07:00
mlugg
d99bed1b10 Sema: optimize runtime array_mul
There are two optimizations here, which work together to avoid a
pathological case.

The first optimization is that AstGen now records the result type of an
array multiplication expression where possible. This type is not used
according to the language specification, but instead as an optimization.
In the expression '.{x} ** 1000', if we know that the result must be an
array, then it is much more efficient to coerce the LHS to an array with
length 1 before doing the multiplication. Otherwise, we end up with a
1000-element tuple which we must coerce to an array by individually
extracting each field.

Secondly, the previous logic would repeatedly extract element/field
values from the LHS when initializing the result. This is unnecessary:
each element must only be extracted once, and the result reused.

These changes together give huge improvements to compiler performance on
a pathological case: AIR instructions go from 65551 to 15, and total AIR
bytes go from 1.86MiB to 264.57KiB. Codegen time spent on this function
(in a debug compiler build) goes from minutes to essentially zero.

Resolves: #17586
2023-11-08 23:55:53 -07:00
Andrew Kelley
a1d688b86a
Merge pull request #17913 from jacobly0/vararg-int
Sema: implement vararg integer promotions
2023-11-08 23:52:59 -07:00
mlugg
997eaf6d87 Sema: do not force resolution of struct field inits when calling function pointer field
b3462b7 caused a regression in a third-party project, since it forced
resolution of field initializers for any field call 'foo.bar()', despite
this only being necessary when 'bar' is a comptime field.

See https://github.com/ziglang/zig/pull/17692#issuecomment-1802096734.
2023-11-08 23:47:10 -07:00
frmdstryr
f258a391da
Speed up ast.tokenLocation 2023-11-09 01:45:25 +00:00
Luuk de Gram
2ac0ba03a6 wasm-linker: ensure symbol fields are set for decls
Previously the symbol tag field would remain `undefined` until it
was set during `flush`. However, the symbol's tag would be observed
earlier than where it was being set. We now set it to the explicit
tag `undefined` so this can be caught during debug. The symbol tag of
a decl will now also be set right after `updateDecl` and `updateFunc`.

Likewise, we now also set the `name` field during atom creation for
decls, as well as set the other fields to the max(u32) to ensure we
get a compiler crash during debug to ensure any misses will be caught.
2023-11-09 00:00:17 +01:00
Veikka Tuominen
10a28bc4c4
Merge pull request #17935 from ianic/fix_io_uring_test_kernel_5_4
Fix io_uring tests on kernel 5.4
2023-11-09 00:49:22 +02:00
Andrew Kelley
be14fe1fa1
Merge pull request #17930 from jacobly0/x86_64
x86_64: pass more tests with an x86_64 backend compiled compiler
2023-11-08 13:51:59 -07:00
Jacob Young
52d8099dae Sema: don't allow passing non-extern types to varargs parameters 2023-11-08 14:43:23 -05:00
Jacob Young
045a5e924c Sema: implement vararg integer promotions 2023-11-08 14:43:23 -05:00
Igor Anić
715e5f757f fix io_uring tests on kernel 5.4
Unsupported tests are now skipped on kernel 5.4:
```
uname -a
Linux d20 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:31:37 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
zig test lib/std/std.zig --zig-lib-dir lib --main-mod-path lib/std 2>&1 | cat
709/2616 test.nop... OK
710/2616 test.readv... OK
711/2616 test.writev/fsync/readv... OK
712/2616 test.write/read... SKIP
713/2616 test.splice/read... SKIP
714/2616 test.write_fixed/read_fixed... OK
715/2616 test.openat... SKIP
716/2616 test.close... SKIP
717/2616 test.accept/connect/send/recv... SKIP
718/2616 test.sendmsg/recvmsg... OK
719/2616 test.timeout (after a relative time)... SKIP
720/2616 test.timeout (after a number of completions)... OK
721/2616 test.timeout_remove... SKIP
722/2616 test.accept/connect/recv/link_timeout... SKIP
723/2616 test.fallocate... SKIP
724/2616 test.statx... SKIP
725/2616 test.accept/connect/recv/cancel... SKIP
726/2616 test.register_files_update... SKIP
727/2616 test.shutdown... SKIP
728/2616 test.renameat... SKIP
729/2616 test.unlinkat... SKIP
730/2616 test.mkdirat... SKIP
731/2616 test.symlinkat... SKIP
732/2616 test.linkat... SKIP
733/2616 test.provide_buffers: read... SKIP
734/2616 test.remove_buffers... SKIP
735/2616 test.provide_buffers: accept/connect/send/recv... SKIP
736/2616 test.accept multishot... SKIP
```
2023-11-08 18:52:03 +01:00
Jakub Konka
0299ed5036 elf: fix 32bit build 2023-11-08 18:45:43 +01:00
Jakub Konka
9bcb432a0e elf: test emitting relocatable 2023-11-08 18:41:09 +01:00
Igor Anić
7a1dbbd4f9 fix io_uring timeout_remove test on kernel 5.4
There is no grantee that `copy_cqes` will return exactly wait_nr number of cqes.
If there are ready cqes it can return > 0 but < wait_nr number of cqes.
2023-11-08 18:25:29 +01:00
Jakub Konka
29d7727254 elf: emit SHN_COMMON symbols in -r mode 2023-11-08 18:15:41 +01:00
Jakub Konka
0b4d398c40 elf: streamline codepaths for different linker modes (object, ar, exe/dyn) 2023-11-08 17:35:56 +01:00
Jakub Konka
a16e6706b3 elf: LLVM emits relocs to undef local symbols - color me surprised! 2023-11-08 15:10:28 +01:00
Jacob Young
e387d30b26 x86_64: fix signed not of more than 64 bits 2023-11-08 08:49:34 -05:00
Jacob Young
6c15c34421 MachO: support -fsingle-threaded mode 2023-11-08 08:40:10 -05:00
Jacob Young
8f2aa72af7 x86_64: fix optional comparison 2023-11-08 07:24:48 -05:00
Jakub Konka
d8b1ef9430 elf: adjust r_addend with offset of the original input section ref'd via STT_SECTION 2023-11-08 12:11:55 +01:00
Frank Denis
a70d8d29d5
Curve25519.fromEdwards25519(): don't assume normalized coordinates (#17920)
The low-level `Curve25519.fromEdwards25519()` function assumed
that the X/Y coordinates were not scaled (Z=1).

But this is not guaranteed to be the case.

In most real-world applications, the coordinates are freshly decoded,
either directly or via the `X25519.fromEd25519()` function, so this
is not an issue.

However, since we offer the ability to do that conversion after
arbitrary computations, the assertion was not correct.
2023-11-08 11:56:56 +01:00
Jakub Konka
ae08f9bfe9 elf: claim unresolved dangling symbols as undef externs in -r mode 2023-11-08 11:51:11 +01:00
Jakub Konka
e87c751558 elf: reference .rela sections via output section index 2023-11-08 10:57:34 +01:00
mlugg
4504e03a18 Sema: fix source location for untyped array init with result type
Resolves: #17923
2023-11-08 06:56:52 +00:00
tison
ee47643b6e
std.math.big: fix sqrt with bits > limb_bits
Signed-off-by: tison <wander4096@gmail.com>
2023-11-08 08:39:08 +02:00
Jakub Konka
5e78600f0f elf: actually track output symtab index of symbols 2023-11-07 23:18:41 +01:00
Andrew Kelley
77bc8e7b67
Merge pull request #17771 from ehaas/mingw-aro
mingw: Use aro instead of clang for preprocessing import libs
2023-11-07 14:47:05 -05:00
dweiller
81219586bc sema: allow slicing [*]T without end 2023-11-07 17:01:32 +02:00
Jakub Konka
ecf6ed7d9b elf: allocate alloc sections when emitting relocatable 2023-11-07 15:04:57 +01:00
Jakub Konka
31b280c78f elf: emit .rela.eh_frame section header if required 2023-11-07 14:47:11 +01:00
Jakub Konka
0211d6bf4f elf: create link between .rela and output section 2023-11-07 14:42:27 +01:00
Jakub Konka
e22b3595c1 elf: update .rela section sizes 2023-11-07 14:29:44 +01:00
David Rubin
03abac3824 fix sqrt(0) 2023-11-07 14:37:43 +02:00
Jakub Konka
c7ed7c4690 elf: generate section symbols when writing symtab 2023-11-07 13:31:31 +01:00
Jakub Konka
3df53d1722 elf: create skeleton of required changes for supporting -r mode 2023-11-07 11:19:55 +01:00
Matthew Lugg
b3462b7cec
Merge pull request #17692 from kcbanner/struct_field_init_pass
sema: analyze struct field bodies in a second pass, to allow them to use the layout of the struct itself
2023-11-07 07:44:32 +00:00
mlugg
d78eda34c5 Sema: emit @intCast safety check correctly for vectors
This code was previously tripping an assertion by not making this value
used in the safety check a vector.
2023-11-07 06:42:15 +00:00
mlugg
9b394a200a Sema: allow destructuring vectors
This was intended to work when destructuring was first implemented, and
was just unintentionally missed out.
2023-11-07 06:11:01 +00:00
Jakub Konka
bf0387b6bb
Merge pull request #17873 from ziglang/elf-archive
elf: implement archiving input object files
2023-11-07 03:22:14 +01:00
Adam Goertz
db785e25b9 Apply same reductions to while 2023-11-07 01:24:19 +00:00
kcbanner
1acb6a53d0
wasm: support rendering unions using their backing type if they have no defined tag type 2023-11-07 00:49:39 +00:00
kcbanner
35c86984a6
cbe: support rendering union values that have no defined tag type
This was regressed in d657b6c0e2, when
the comptime memory model for unions was changed to allow them to have
no defined tag type.
2023-11-07 00:49:39 +00:00
kcbanner
f10499be0a
sema: analyze field init bodies in a second pass
This change allows struct field inits to use layout information
of their own struct without causing a circular dependency.

`semaStructFields` caches the ranges of the init bodies in the `StructType`
trailing data. The init bodies are then resolved by `resolveStructFieldInits`,
which is called before the inits are actually required.

Within the init bodies, the struct decl's instruction is repurposed to refer
to the field type itself. This is to allow us to easily rebuild the inst_map
mapping required for the init body instructions to refer to the field type.

Thanks to @mlugg for the guidance on this one!
2023-11-07 00:49:35 +00:00
Andrew Kelley
234693bcbb tests: skip native CPU std tests on Windows
See tracking issue #17902
2023-11-06 16:03:04 -07:00
XXIV
5ea973dc39 langref: fix malloc return type 2023-11-06 23:46:17 +02:00
Jakub Konka
261db02018 CheckObject: support parsing and dumping archive symtab for ELF 2023-11-06 21:18:26 +01:00
Jacob Young
9ced27dace x86_64: fix passing register-sized payload as non-reigster-sized union
Closes #17885
2023-11-06 14:11:31 -05:00