19735 Commits

Author SHA1 Message Date
Joachim Schmidt
d2342370fe
Merge pull request #12438 from joachimschmidt557/stage2-arm
stage2 ARM: misc improvements
2022-08-13 20:32:18 +00:00
joachimschmidt557
c9d9fd53a6
stage2 ARM: add inline memcpy to genSetStack 2022-08-13 17:00:03 +02:00
joachimschmidt557
91969ad908
stage2 ARM: Fix tracking of function return values 2022-08-13 17:00:03 +02:00
joachimschmidt557
4c5156544b
stage2 ARM: pass stack arguments in opposite order
Earlier arguments have a smaller address (i.e. towards the bottom of
the stack)
2022-08-13 17:00:00 +02:00
Cody Tapscott
7e07f3d4f9 stage2 astgen: Use rl semantics for @Type
Resolves #12430.
2022-08-13 09:22:25 +03:00
Jakub Konka
bfe8a4d9f6
Merge pull request #12425 from ziglang/dwarf-fixes
x86: fix generating debug info for variables
2022-08-12 21:48:34 +02:00
Jakub Konka
aeaffd42f6 x86: fix generating debug info for variables
Add handling for these additional `MCValue`s:
* `.immediate` - lower to `DW.OP.consts` or `DW.OP.constu` depending
  on signedness followed by popping off the DWARF stack with
  `DW.OP.stack_value`
* `.undef` - lower to `DW.OP.implicit_value`
* `.none` - lower to `DW.OP.lit0` followed by popping off the DWARF
  stack with `DW.OP.stack_value`

For any remaining unhandled case, we generate `DW.OP.nop` in order
not to mess up remaining DWARF info.
2022-08-12 12:05:34 +02:00
Jakub Konka
f2f1bb7cb6 macho: update __DWARF sections before and after writing out __LINKEDIT 2022-08-12 11:50:39 +02:00
martinhath
92568a0097
Sema: add error for signed integer division
stage1 error reads

error: division with 'i32' and 'comptime_int': signed integers must use @divTrunc, @divFloor, or @divExact

Fixes: #12339
2022-08-12 11:45:11 +03:00
Andrew Kelley
fa50e179f7
Merge pull request #12381 from hdorio/12380-fix-reporting-success
ci: windows: stop when exe exits with an error
2022-08-12 03:51:09 -04:00
Luuk de Gram
645c396d02
Merge pull request #12394 from Luukdegram/wasm-reuse-locals
stage2: wasm - reuse (temporary) locals
2022-08-12 08:07:09 +02:00
Andrew Kelley
5e42b0821a disable failing stack traces tests on windows
See tracking issue #12422
2022-08-11 19:19:23 -07:00
Andrew Kelley
486626beb7 disable failing link tests on windows
See tracking issue #12421
2022-08-11 17:53:15 -07:00
Andrew Kelley
23a227a073 disable failing standalone test: issue_11595
See tracking issue #12419
2022-08-11 17:53:12 -07:00
Andrew Kelley
dba758da18 disable failing C backend behavior test on Windows
See tracking issue #12415
2022-08-11 12:56:46 -07:00
Andrew Kelley
64307c2821 CI: update windows tarball 2022-08-11 12:48:11 -07:00
Hadrien Dorio
bcc6cdc4fb ci: azure: stop when exe exits with an error 2022-08-11 12:48:11 -07:00
Andrew Kelley
e67a43a673
Merge pull request #12410 from ifreund/sig-err-dfl-ign-fix
std: fix definition of SIG_IGN, SIG_DFL, etc.
2022-08-11 15:05:07 -04:00
LordMZTE
bbcc26a9b6 fix error message when providing slice to std.hash.autoHash 2022-08-11 21:44:33 +03:00
Andrew Kelley
a82d7c2063 std: add missing error to windows.WriteFile
I encountered this error today when testing the self-hosted compiler on
Windows.
2022-08-11 06:22:05 -04:00
Andrew Kelley
44a6172edb
Merge pull request #12405 from ziglang/macho-aligned-ptrs
link.MachO: use accurate alignment attribute on pointers
2022-08-11 06:19:10 -04:00
Isaac Freund
b78f3bf1f1
std: fix definition of SIG_IGN, SIG_DFL, etc.
POSIX specifies that the sa_handler field of the sigaction struct may
be set to SIG_IGN or SIG_DFL. However, the current constants in the
standard library use the function pointer signature corresponding to
the sa_sigaction field instead.

This may not cause issues in practice because the fields usually occupy
the same memory in a union, but this isn't required by POSIX and there
may be systems we do not yet support that do this differently.

Fixing this also makes the Zig interface less confusing to use after
reading the man page.
2022-08-11 12:09:34 +02:00
Luuk de Gram
b42ba7c3d4
wasm: free unused locals
When a local is no longer referenced or used, free it
so the local can be re-used by another instruction.
This means we generate less locals. Freeing this local
is a manual action and must only be used on temporaries
or where we are sure the local is not referenced by a
different AIR instruction, as that creates UB.

We now also no longer store a `WValue` when its tag is set to `none`
as those may never be referenced by any AIR instruction.
An assertion is done to make sure we never store a reference to a
`stack` value in our resolved instructions.
2022-08-11 11:08:01 +02:00
Luuk de Gram
a5e4fd7ef6
wasm: keep load values on the stack
We internally use a lot of `load`'s that used to put
the result in a newly created local. For instance, when is considered
byRef or when we need a specific field/element/bytes from a larger type.
However, sometimes we want to directly use this value and then forget about
it, which means storing it in a local first is wasted instructions as well
as wasted locals that shouldn't be generated in the first place.
With this change it's explicit and requires the usage of `toLocal`.
2022-08-11 11:08:00 +02:00
Luuk de Gram
3cd0cd12a0
wasm: leave signedAbsValue values on the stack 2022-08-11 11:08:00 +02:00
Luuk de Gram
cde16f61eb
wasm: wrapOperand - leave value on the stack
This also does it for `wrapBinOp` which internally uses the already
refactored `binOp` and `wrapOperand` heavily simplifying this
function and not duplicate the logic from `binOp`
2022-08-11 11:08:00 +02:00
Luuk de Gram
699bc6171d
wasm: Keep intcast values on stack 2022-08-11 11:08:00 +02:00
Luuk de Gram
305b113a53
wasm: keep result of cmp on the stack
By keeping the result on the stack, we prevent codegen
from generating unneccesary locals when we have subsequent instructions
that do not have to be re-used.
2022-08-11 11:08:00 +02:00
Luuk de Gram
cc6f2b67c6
wasm: binOp leave value on stack
Rather than always creating a new local and storing the result of
a binary operation into said local, we now leave it on top of the stack.
This allows for better codegen as we need less instructions, as well
as less total amount of locals.
2022-08-11 11:08:00 +02:00
Luuk de Gram
7e6dbd6398
wasm: Use free-lists for unused locals
When a local is no longer needed (for instance, it was used as
a temporary during arithmetic), it can be appended to one of
the typed freelists. This allows us to re-use locals and therefore
require less locals, reducing the binary size, as well as runtime
initialization.
2022-08-11 11:07:56 +02:00
Isaac Freund
7d6a7f513b
std: Don't pass undefined memory to the kernel in os.abort() 2022-08-11 11:05:53 +02:00
Andrew Kelley
9f1f60fd43 test-cases: remove multi-threading
This effectively reverts 22690efcc2378222503cb8aaad26a6f4a539f5aa,
re-opening #11818.

This had the following problems:
 * Buggy on some targets (macOS, Windows)
 * Messy output to the terminal

These problems need to be solved before moving forward with this.
2022-08-11 00:46:44 -07:00
Andrew Kelley
933436dc52 stage2: remove destroyed functions from maps
This is likely the cause of the flaky test failures in master branch.
Since we have some test coverage for incremental compilation, it's not
OK to leave proper memory management of Fn objects as "TODO".
2022-08-10 23:23:30 -07:00
Andrew Kelley
fa620ef710 link.MachO: use accurate alignment attribute on pointers
Also adds a new method to ArrayList: appendUnalignedSlice
2022-08-10 22:28:05 -07:00
Andrew Kelley
cc56400e62 Revert "macho: allow unaligned offsets in object files"
This reverts commit 45c444ff18b43d30a7277e346174ba6eca4a6193.
2022-08-10 22:27:59 -07:00
Veikka Tuominen
74673b7f69 stage2 llvm: implement more C ABI 2022-08-10 20:52:36 -04:00
Andrew Kelley
4d7f5a1917 stage2: fix crash with comptime vector reduce 2022-08-10 16:45:29 -07:00
Andrew Kelley
3c4e9b5983 disable failing behavior test
See #12360
2022-08-10 16:43:47 -07:00
Andrew Kelley
d267f0f968 LLVM: respect linksection for exported variables 2022-08-10 16:43:30 -07:00
Andrew Kelley
e8d02c5b90 add ZIG_GLOBAL_CACHE_DIR env var 2022-08-10 16:43:25 -07:00
Andrew Kelley
9656ec271c better default for use_stage1 when -ofmt=c is provided 2022-08-10 16:24:04 -07:00
Andrew Kelley
173952f4b8 disable failing behavior test
see tracking issue #12396
2022-08-10 16:13:59 -07:00
Andrew Kelley
e0178890ba
Merge pull request #12379 from ifreund/packed-struct-explicit-backing-int
stage2: Implement explicit backing integers for packed structs
2022-08-10 19:13:29 -04:00
Jakub Konka
45c444ff18 macho: allow unaligned offsets in object files 2022-08-10 18:45:46 -04:00
InKryption
e218b7ea0c stage2: add compile error for invalid null/undefined pointer cast 2022-08-10 16:39:46 -04:00
LeRoyce Pearson
0e118ed0ac stage2: add compile error for shlExact overflow
- moves a stage1 test case and makes it target `llvm` backend instead
  of `stage1` backend
2022-08-10 16:14:30 -04:00
zooster
8fd20a5eb0 fix: disallow newline in char literal 2022-08-10 16:13:56 -04:00
Veikka Tuominen
40447b25e8 Sema: fix expansion of repeated value
Closes #12386
2022-08-10 15:18:09 -04:00
Isaac Freund
0d32b73078
stage2: Implement explicit backing integers for packed structs
Now the backing integer of a packed struct type may be explicitly
specified with e.g. `packed struct(u32) { ... }`.
2022-08-10 19:54:45 +02:00
Isaac Freund
bb1c3e8b7e
stage2: Handle lazy values for the % operator 2022-08-10 14:48:27 +02:00