4431 Commits

Author SHA1 Message Date
Jakub Konka
b5601a2da6 link-tests: extract values into variables
We can then collect multiple variables (currently assumed always
in global scope) and run a comparison with some very basic
arithmetic on the values.
2022-06-22 00:49:22 +02:00
Jakub Konka
3bb4d65b2f link-tests: move macho tests to subfolder
Handle `-e` option in MachO linker allowing the user to set a custom
entrypoint address.
2022-06-21 23:01:09 +02:00
Jakub Konka
937464f398 link-tests: dump metadata to string and grep results
This approach is more inline with what LLVM/LLD does for testing
of their output, and seems to be more generic and easier to extend
than implementing a lot of repetitive and nontrivial comparison
logic when working directly on structures.
2022-06-21 22:19:57 +02:00
Jakub Konka
5fbdfb3f34 link-tests: add CheckMachOStep
CheckMachOStep specialises CheckFileStep into directed (surgical)
MachO file fuzzy searches. This will be the building block for
comprehensive MachO linker tests.
2022-06-21 15:44:24 +02:00
Jakub Konka
2d09540a63 link-tests: test pagezero_size option for macho 2022-06-20 18:25:20 +02:00
Jakub Konka
6e56a8df20 link-tests: CheckFileStep to do grep test on the binary 2022-06-20 17:59:17 +02:00
Jakub Konka
38edef35bf test: introduce link(er) tests - builds on standalone tests 2022-06-20 17:59:17 +02:00
Luuk de Gram
4957c7cbbd
wasm: enable passing behavior tests
This also splits the test cases for addition and subtraction as the wasm
backend does not yet provide support for 128bit saturating arithmetic.
2022-06-19 17:27:56 +02:00
Andrew Kelley
33cf6ef621
Merge pull request #11881 from Vexu/stage2
Stage2: fixes for bugs found while looking for miscompilations
2022-06-17 19:23:08 -04:00
Xavier Bouchoux
b66247c97a stage2: coerce tuple to vector 2022-06-17 19:06:17 +03:00
Omar Alhammadi
69e2cac0d3
stage2: comptime @bitCast packed struct bug fix 2022-06-17 19:04:51 +03:00
Veikka Tuominen
b9dcbe6b4c Sema: handle sentinels in tupleToArray 2022-06-17 18:57:02 +03:00
Andrew Kelley
8caa206417 test-cases: fix race with zig run on C backend tests
Also avoid redundantly doing compile-error checks on multiple targets
for test cases where that is not helpful.
2022-06-14 15:27:43 -07:00
Andrew Kelley
13f02c30e6 stage2: fix some inline asm incompatibilities with stage1 2022-06-12 14:46:05 -07:00
Andrew Kelley
ffa700ee58
Merge pull request #11837 from Vexu/stage2
Fix (nearly) all stage2 crashes when testing stdlib
2022-06-12 17:45:57 -04:00
Veikka Tuominen
0a9d6956e7 Sema: add missing set_union_tag 2022-06-12 19:17:41 +03:00
Andrew Kelley
e64d5a0753 Sema: rework beginComptimePtrMutation
This comment is now deleted because the task is completed in this
commit:

```
// TODO: Update this to behave like `beginComptimePtrLoad` and properly check/use
// `container_ty` and `array_ty`, instead of trusting that the parent decl type
// matches the type used to derive the elem_ptr/field_ptr/etc.
//
// This is needed because the types will not match if the pointer we're mutating
// through is reinterpreting comptime memory.
```

The main strategy is to change the ComptimePtrMutationKit struct so that
instead of `val: *Value` it now returns a tagged union which can be one
of three possibilities:

 * The pointer type matches the actual comptime Value so a direct
   modification is possible. Before this commit, the implementation
   incorrectly assumed this was always the case.

 * In the case of needing to write through a reinterpreted pointer, a
   mutable base Value pointer is provided along with a byte offset
   pointing to the element value in virtual memory.

 * Otherwise, it means a compile error must be emitted because one or
   both of the types (the owner of the value, or the pointer type being
   used to write through) do not have a well-defined memory layout.

After calling beginComptimePtrMutation, the one callsite now switches on
this tagged union and does the appropriate thing. The main new logic is
for the second case, which involves pointer reinterpretation, which now
takes this strategy:

 1. write the base value to a memory buffer.
 2. perform the pointer store at the proper byte offset, thereby
    modifying a subset of the buffer.
 3. read the base value from the memory buffer, overwriting the old base
    value.
2022-06-12 01:33:56 -07:00
Veikka Tuominen
35c7e376b8 stage2: improve anon name strategy for local variables 2022-06-11 23:49:33 +03:00
Veikka Tuominen
0333ff4476 stage2: make error{} the same size as anyerror
Having `error{}` be a zero bit type causes issues when it interracts
with empty inferred error sets which are the same size as `anyerror`.
2022-06-11 23:49:33 +03:00
Veikka Tuominen
488e1e5f51 stage2: small fixes + adjustments to std tests 2022-06-11 23:49:33 +03:00
Veikka Tuominen
eaa6b04c3c Sema: skip decl causing namespace lookup when doing lookup 2022-06-11 11:02:56 +03:00
Andrew Kelley
c1eb6c30e8
Merge pull request #11835 from ziglang/stage2-behavior
stage2: fix handling of aggregates with mixed comptime-only fields
2022-06-11 00:27:41 -04:00
Andrew Kelley
3c3bc5af29 Sema: introduce bitSizeAdvanced to recursively resolve types
Same pattern as abiSizeAdvanced.

Fixes compiler crash for nested packed structs.
2022-06-10 15:04:39 -07:00
Andrew Kelley
58bc562cb4 update packed struct behavior tests to new language semantics 2022-06-09 20:37:24 -07:00
Andrew Kelley
436aafd3e2 remove a stage2 test case that relies on a very deep compiler stack
It's causing Drone CI failure on aarch64. I will open a follow-up issue
to track this missing test case.
2022-06-09 20:00:59 -07:00
Andrew Kelley
32c90cb553 stage2: fix handling of aggregates with mixed comptime-only fields 2022-06-09 19:23:36 -07:00
Andrew Kelley
fd32f6890d stage2: fold redundant error notes 2022-06-09 15:37:16 -07:00
Andrew Kelley
83f300218f upgrade behavior test to stage2 fn ptr semantics 2022-06-09 15:37:16 -07:00
Andrew Kelley
f4d5fcde72 AstGen: avoid redundant "ref" instructions
Whenever a `ref` instruction is needed, it is created and saved in
`AstGen.ref_table` instead of being immediately appended to the current
block body. Then, when the referenced instruction is being added to the
parent block (e.g. from setBlockBody), if it has a ref_table entry, then
the ref instruction is added directly after the instruction being referenced.
This makes sure two properties are upheld:
1. All pointers to the same locals return the same address. This is required
   to be compliant with the language specification.
2. `ref` instructions will dominate their uses. This is a required property
   of ZIR.

A complication arises when a ref instruction refs another ref
instruction. The logic in appendBodyWithFixups must take this into
account, recursively handling ref refs.
2022-06-08 20:40:16 -07:00
Andrew Kelley
7c0614ea65 Sema: implement zirRetErrValueCode 2022-06-08 15:51:48 -07:00
Andrew Kelley
d557dedf6c add a missing align() to a behavior test 2022-06-08 15:38:15 -07:00
Andrew Kelley
434226c89d stage2: fix type printing of sub-byte pointers 2022-06-08 15:18:43 -07:00
Andrew Kelley
53c86febcb stage2: packed struct fixes for big-endian targets 2022-06-07 22:47:08 -07:00
Andrew Kelley
3e30ba3f20 stage2: better codegen for byte-aligned packed struct fields
* Sema: handle overaligned packed struct field pointers
 * LLVM: handle byte-aligned packed struct field pointers
2022-06-07 21:05:40 -07:00
Andrew Kelley
6ff7b437ff
Merge pull request #11813 from Vexu/stage2
`zig2 build test-std` finale
2022-06-07 20:07:28 -04:00
Jakub Konka
3cb3873382
Merge pull request #11814 from ziglang/x64-stack-handling
x64: improves stack handling, fixes a heisenbug, adds micro-optimisations
2022-06-07 23:22:20 +02:00
Jakub Konka
6c59aa9e02
Merge pull request #11806 from koachan/sparc64-codegen
stage2: sparc64: Some more Air lowerings
2022-06-07 21:24:56 +02:00
Veikka Tuominen
e4c0b848a4 Sema: allow simple else body even when all errors handled 2022-06-07 21:27:06 +03:00
Veikka Tuominen
d5e3d5d74c Sema: make analyzeIsNonErr even lazier for inferred error sets 2022-06-07 21:27:06 +03:00
Jakub Konka
a8bce8f14b x64: pass behavior test bugs/1381 2022-06-07 19:33:43 +02:00
Andrew Kelley
e9fc58eab7 LLVM: handle extern function name collisions
Zig allows multiple extern functions with the same name, and the
backends have to handle this possibility.

For LLVM, we keep a sparse map of collisions, and then resolve them in
flushModule(). This introduces some technical debt that will have to be
resolved when adding incremental compilation support to the LLVM
backend.
2022-06-07 00:47:10 -04:00
Jakub Konka
d9b0c984aa
Merge pull request #11794 from ziglang/elf-macho-alignment
elf+macho: use explicit alignment on Decl if specified
2022-06-07 01:03:15 +02:00
Andrew Kelley
367e2b2fe4
Merge pull request #11800 from Vexu/stage2
`zig2 build test-std` progress
2022-06-06 16:12:31 -04:00
Veikka Tuominen
84000aa820 Sema: fix inline call of func using ret_ptr with comptime only type 2022-06-06 13:11:50 -07:00
Veikka Tuominen
8fa88c88c2 AstGen: fix coercion scope type when stores are eliminated 2022-06-06 13:11:50 -07:00
Veikka Tuominen
cb5d2b691a Sema: validate equality on store to comptime field 2022-06-06 13:11:50 -07:00
Veikka Tuominen
a040ccb42f Sema: fix coerce result ptr outside of functions 2022-06-06 13:11:50 -07:00
Andrew Kelley
41bf81dc32 Revert "Treat blocks with "return" as "noreturn""
This reverts commit 135b91aecd9be1f6f5806b667e07e383dd481198.

"endsWithBreak()" is not a meaningful question to ask and should not be
used this way. A simple example that defeats this logic is:

```zig
export fn entry() void {
    outer: {
        {
            break :outer;
        }
        return;
    }
}
```
2022-06-06 11:31:54 -07:00
Koakuma
97d35a5147 behaviortest: Skip 'align(N) on functions' on sparc64 for now 2022-06-06 21:17:09 +07:00
BratishkaErik
1bdc2b777b tools: fix update-linux-headers.zig and process_headers.zig
Signed-off-by: BratishkaErik <bratishkaerik@getgoogleoff.me>
2022-06-06 15:53:53 +02:00