20767 Commits

Author SHA1 Message Date
Veikka Tuominen
be9a4a1f97 Sema: handle noreturn in boolBr
Closes #13112
2022-10-17 18:53:15 +03:00
Jacob Young
1e963053d0 tools: add lldb stage2 pretty printers
* Fix untagged struct names in debug info for llvm.
 * Factor out common stage2 pretty printer data.
 * Add lldb version of stage2 pretty printers.
2022-10-17 07:55:28 -04:00
Andrew Kelley
c010767311
Merge pull request #13193 from Luukdegram/wasm-locals
stage2: Wasm - Integrate lifeness analysis for locals reusal
2022-10-17 07:51:07 -04:00
Jacob Young
1e0f74a9e6 emutls: add const to default_value field
Commit f14cc75 accidentally added a const when grepping for assignments
to `std.builtin.Type.StructField.default_value`, however when looking
into it further, I noticed that even though this default_value field is
emitted into the .data section, the value it points to is actually
emitted into the .rodata section, so it seems correct to use const here.
2022-10-17 07:50:01 -04:00
Naoki MATSUMOTO
059e397ffc std.os: handle error.UnreachableAddress in send() 2022-10-17 13:10:23 +02:00
Evin Yulo
f36aee93cc Give better error message for --name with folder separator 2022-10-17 13:06:06 +02:00
Jens Goldberg
1459231624 fix setsockopt returning ENODEV 2022-10-17 12:55:12 +02:00
Ali Chraghi
5127dae7a2 std.os: fix execv* doc comment 2022-10-16 11:38:22 -04:00
dan
ca1c185eb6
std.zig: search include dir and lib dir from environment variables (#13145)
* minor fix based on feedback from @marler8997

Co-authored-by: dan <i@dan.games>
2022-10-16 11:37:35 -04:00
bfredl
c750d95417 os.linux: some fixes to BPF module
- For ALU operations, src should be allowed to be an explicit Reg.
- Expose AluOp and JmpOp as public types.
  This makes code generation using BPF as a backend easier,
  as AluOp and JmpOp can be used directly as part of an IR
2022-10-16 11:36:11 -04:00
Evin Yulo
b346d48572 Simplify code in std.meta.isTag 2022-10-16 11:35:27 -04:00
Meghan
c37b40248c stage2: remove --verbose-mir from help menu
removed in 5f97652da8
2022-10-16 11:35:06 -04:00
Luuk de Gram
0aa23fe8b7
wasm: rename 'self' to more explanatory name
'Self' isn't a very good name to describe what it does.
This commit changes the type name into `CodeGen` and the parameter
to `func` as we're generating code for a function.
With this change, the backend's coding style is in line with the
self-hosted Wasm-linker.
2022-10-16 15:54:56 +02:00
Luuk de Gram
ff1cab037c
wasm: re-use operands
When we return an operand directly as a result, we must call
`reuseOperand`. This commit ensures it's done for all currently-
implemented AIR instructions.
2022-10-16 15:54:17 +02:00
Luuk de Gram
273b8e20ca
wasm: allow merging single branches
Rather than accepting a canonical branch and a target branch
we allow to directly merge a branch into the parent branch.
This is possible as there's no overlapping and we have infinite
registers to our availability. This makes merging a lot simpler.
2022-10-16 15:54:17 +02:00
Luuk de Gram
6fcd72355c
wasm: correctly get the type of a local for free
When determining the type of a local (read: register), we would
previously subtract the stack locals also. However, this locals
are also within the same `locals` list, meaning the type of the
local we were retrieving was off by 2. This could create a validation
error when we re-use a local of a different type.
2022-10-16 15:54:17 +02:00
Luuk de Gram
e62bb1d689
wasm: implement branching
Upon a branch, we only allow locals to be freed which were allocated
within the same branch as where they die. This ensures that when two
or more branches target the same operand we do not try to free
it more than once. This does however not implement freeing the local
upon branch merging yet.
2022-10-16 15:54:16 +02:00
Luuk de Gram
576bb3f0a9
wasm: de -and increment reference count locals
When reusing an operand it increases the reference count, then when
an operand dies it will only decrease the reference count. When
this reaches 0, the local will be virtually freed, meaning it can be
re-used for a new local.
2022-10-16 15:54:16 +02:00
Luuk de Gram
b17c8c5424
wasm: reference count locals
By reference counting the locals, we can ensure that when we free
a local, no local will be reused while it still has references pointing
to it. This prevents misscompilations. The compiler will also panic if
we free a local more than we reference it, introducing extra safety to
ensure they match up.
2022-10-16 15:54:16 +02:00
Luuk de Gram
b9b20b14ea
wasm: use liveness analysis for locals
This hooks reusal of locals into liveness analysis.
Meaning that when an operand dies, and is a local,
it will automatically be freed so it can be re-used
when a new local is required. The result of this, is
a lower allocation required for locals. Having less
locals means smaller binary size, as well as faster
compilation speed when loaded by the runtime.
2022-10-16 15:54:16 +02:00
Isaac Yonemoto
99c3578f69
adds isTag function to std.meta (#11895) 2022-10-15 14:32:05 -04:00
Andrew Kelley
c0d7f64036
Merge pull request #12448 from r00ster91/ultimateascii
std.ascii: rename functions and other improvements
2022-10-15 14:28:33 -04:00
Jacob Young
f9192adaba llvm: fix lowering of non-byte-aligned field pointers
* When a field starts at some bit offset within a byte you need to load
   starting from that byte and shift, not starting from the next byte,
   so a rounded-down divide is required here, not a rounded-up one.
 * Remove paragraph from doc that no longer relates to anything.

Closes #12363
2022-10-15 14:19:40 -04:00
Jacob Young
c7f9833238 Module: fix early exit conditions during compilation
* `--verbose-llvm-ir` should trigger analysis and codegen
 * `-femit-asm` etc should trigger codegen even with `-fno-emit-bin`

Closes #12588
2022-10-15 14:18:35 -04:00
Jacob Young
cb0e22db4e llvm: fix lowering of runtime refs to comptime-only decls
When we want a runtime pointer to a zero-bit value we use an undef
pointer, but what if we want a runtime pointer to a comptime-only value?
Normally, if `T` is a comptime-only type such as `*const comptime_int`,
then `*const T` would also be a comptime-only type, so anything
referencing a comptime-only value is usually also comptime-only, and
therefore not emitted to the executable.

However, what if instead we have a `*const anyopaque` pointing to a
comptime-only value?  Certainly, `*const anyopaque` is a runtime type,
and so we need some runtime value to store, even when it happens to be
pointing to a comptime-only value.  In this case we want to do the same
thing as we do when pointing to a zero-bit value, so we use
`hasRuntimeBits` to handle both cases instead of ignoring comptime.

Closes #12025
2022-10-15 14:17:25 -04:00
Andrew Kelley
feab1ebe1b
Merge pull request #12878 from gwenzek/ptx
Update Nvptx backend for Zig 0.10
2022-10-15 13:53:04 -04:00
Andrew Kelley
c289794f0d nvptx: add TODO comment regarding abuse of llvm builtins 2022-10-15 10:50:02 -07:00
Guillaume Wenzek
24c749473a implement os.abort and panic for cuda 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
419855c475 fix test 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
ac1f17f63f disable sema.addConstant 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
b425d88737 re-enable nvptx tests 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
577f0aa54b addrSpaceCastIsValid nvptx 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
aad983cf40 sanitize qualified name for nvptx backend 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
92a857b76c debug 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
004fca2c64 restore comp when leaving flushModule 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
b3dc80a1e3 disable debug info for ptx<7.5 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
85c6b0f0bc allow ptx kernel export 2022-10-15 10:39:19 -07:00
Andrew Kelley
65f860bef7
Merge pull request #12879 from Snektron/amdgpu-improvements
Amdgpu improvements
2022-10-15 13:36:43 -04:00
Andrew Kelley
66d6183001 Merge branch 'amdgpu-improvements' of https://github.com/Snektron/zig into Snektron-amdgpu-improvements 2022-10-15 10:36:10 -07:00
Andrew Kelley
1087e67762
Merge pull request #13108 from topolarity/llvm-lib-dir
build.zig: Forward LLVM lib/include dirs from CMake
2022-10-15 12:36:38 -04:00
Andrew Kelley
16cc65242f
Merge pull request #12918 from jacobly0/math-cast-comptime-int
std.math: fix behavior relating to comptime_int arguments
2022-10-15 12:11:55 -04:00
Jacob Young
400319872b llvm: fix bug lowering aggregate_init with a byref sentinel
Closes #12972
2022-10-15 11:12:04 -04:00
xEgoist
ae39e7867d Added os check for std.fs.setAsCwd() to work with windows
Due to the unavailability of fchdir in Windows, a call for setting the
CWD needs to either call chdir with the path string or call
SetCurrentDirectory.
Either way, since we are dealing with a Handle in Windows, a call for
GetFinalPathNameByHandle is necessary for getting the file path first.
2022-10-15 11:05:15 -04:00
Andrew Kelley
b4e3424594
Merge pull request #13100 from topolarity/powerpc64le
stage2: Fix softfloat support for PPC64(LE)
2022-10-15 10:05:00 -04:00
Luuk de Gram
74108bb9c0 test/link: fix Wasm archive test
As memcpy is now part of compiler-rt, we no longer expect
any imports in the binary.
2022-10-15 07:02:38 -07:00
Luuk de Gram
f5edaa96dd compiler_rt: Move mem implementations from c.zig
This moves functions that LLVM generates calls to,
to the compiler_rt implementation itself, rather than c.zig.
This is a prerequisite for native backends to link with compiler-rt.
This also allows native backends to generate calls to `memcpy` and the like.
2022-10-15 07:02:38 -07:00
Cody Tapscott
a168893e00 stage1: Fix ppcle long double size
Resolves #13110
2022-10-14 13:35:10 -07:00
Ryan Liptak
8bb2e96ac3 std.os.windows: Change HKEY to *opaque {}
The definition of HKEY__ as a struct with an unused int field is only the case in the Windows headers when `STRICT` is defined. From https://learn.microsoft.com/en-us/windows/win32/winprog/enabling-strict:

> When STRICT is defined, data type definitions change as follows:
>
> -  Specific handle types are defined to be mutually exclusive; for example, you will not be able to pass an HWND where an HDC type argument is required. Without STRICT, all handles are defined as HANDLE, so the compiler does not prevent you from using one type of handle where another type is expected.

Zig's `opaque {}` already gives this benefit to us, so the usage of a struct with an unused field is unnecessary, and it was causing HKEY to have an alignment of 4, which is a problem because there are HKEY constants like HKEY_LOCAL_MACHINE (0x80000002) that are not 4-byte aligned. Without this change, the compiler would not allow something like HKEY_LOCAL_MACHINE to be defined since it enforces pointer alignment.
2022-10-14 15:23:13 -04:00
Evan Haas
e4e1c21e1f i386 ABI: Fix some sizes and alignments
This makes the following changes for i386:

long long and unsigned long long have 4 byte alignment on non-Windows

f64 (double) has 4-byte alignment on non-Windows

long double is 80 bits and has 4 byte alignment on mingw

long double on android is 64 bits, not 80: https://www.uclibc.org/docs/psABI-i386.pdf

Fixes #12453
Fixes #12987
2022-10-14 15:22:00 -04:00
Ryan Liptak
c8da03a0e1 Fix compile error in Dir.deleteTreeMinStackSize and add test
Follow up to #13073
2022-10-14 14:48:23 -04:00