4406 Commits

Author SHA1 Message Date
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
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
Gregory Anders
135b91aecd
Treat blocks with "return" as "noreturn"
Block statements that end with "break" should not be considered
"noreturn" for the enclosing scope, but other "noreturn" instructions
(return, panic, compile error, etc.) should be. This differentiation
necessitates handling "break" differently from the other "noreturn"
instructions when inside a block statement.
2022-06-06 13:13:52 +03:00
Jakub Konka
95966f6fd7 elf+macho: use explicit alignment on decl is specified 2022-06-05 16:46:50 +02:00
Jakub Konka
33826a6a2e x64: disable misbehaving behavior tests 2022-06-05 10:36:54 +02:00
Jakub Konka
1b5dd4e148
Merge pull request #11790 from joachimschmidt557/stage2-arm
stage2 ARM: implement basic switch expressions
2022-06-05 09:10:12 +02:00
joachimschmidt557
d5ee451177
stage2 ARM: introduce support for basic switch expressions 2022-06-04 19:58:34 +02:00
Veikka Tuominen
50a6b0f3ac Sema: fix function type callconv inference 2022-06-04 11:33:18 +03:00
Veikka Tuominen
2b93546b39 Sema: fix initialization of array with comptime only elem type 2022-06-03 20:21:20 +03:00
Andrew Kelley
288e89b606 Sema: fix compiler crash with comptime arithmetic involving @ptrToInt 2022-06-01 16:45:28 -07:00
Andrew Kelley
a4cdb49a58
Merge pull request #11763 from Vexu/stage2-alloc-const
Stage2: detect when initializer of const variable is comptime known
2022-06-01 18:59:13 -04:00
Andrew Kelley
b82cccc9e9 Sema: fix alignment of element ptr result type 2022-06-01 15:43:21 -07:00
Veikka Tuominen
94624893d8 disable failing test 2022-06-01 13:06:31 +03:00
Veikka Tuominen
9431100736 Sema: apply previous changes to validateUnionInit 2022-06-01 13:01:39 +03:00
Veikka Tuominen
36df79cd37 stage2: ignore generic return type when hashing function type
Generic parameter types are already ignored.
2022-05-31 16:43:58 +03:00
Veikka Tuominen
febc7d3cd6 Sema: take dbg_stmt into account in zirResolveInferredAlloc 2022-05-31 16:22:00 +03:00
Andrew Kelley
c3ef4ac15f
Merge pull request #11752 from ziglang/zir-fancy-fns
stage2: add missing data to ZIR encoding of functions
2022-05-30 21:18:10 -04:00
Andrew Kelley
c84f5a5f91
Merge pull request #11749 from Vexu/stage2
Stage2: improve AstGen for array init expressions
2022-05-30 17:35:18 -04:00
Andrew Kelley
bd89a73d52 Sema: implement functions generic across callconv() or align() 2022-05-30 14:16:28 -07:00
Veikka Tuominen
0e8307789a AstGen: add tuple aware elem_type_index 2022-05-29 13:19:03 +03:00
Veikka Tuominen
c7b778992e AstGen: improve generated Zir for array init exprs 2022-05-29 13:19:03 +03:00
Veikka Tuominen
0274e2f1fd translate-c: check variable types being demoted to opaque 2022-05-29 12:07:29 +03:00
TwoClocks
36b4658752 translate-c: check record fields for opaque demotions 2022-05-29 12:06:37 +03:00
Veikka Tuominen
ee651c3cd3 Revert "reserve correct space for bitfields"
This reverts commit 22cb6938891c73d64b749a2516c8eaf79aa25b03.
2022-05-29 12:04:50 +03:00
TwoClocks
22cb693889 reserve correct space for bitfields 2022-05-28 17:31:26 +03:00
joachimschmidt557
ddd5b57045 stage2 AArch64: complete genTypedValue 2022-05-27 16:43:11 -04:00
Andrew Kelley
4994ac18e4
Merge pull request #11733 from Vexu/stage2
more misc stage2 fixes
2022-05-27 16:20:49 -04:00