960 Commits

Author SHA1 Message Date
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
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
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
Veikka Tuominen
0fd90749d1 stage2: generate call arguments in separate blocks 2022-08-09 16:19:55 +03:00
Meghan Denny
0879cbeed2 remove 'builtin.stage2_arch', Sema is smart enough now 2022-08-07 16:07:08 -07:00
Veikka Tuominen
eec2978fac Sema: better safety check on switch on corrupt value 2022-08-05 22:13:57 +03:00
Veikka Tuominen
292906fb23 Sema: fix reify Fn alignment and args 2022-08-02 18:33:03 +03:00
Veikka Tuominen
e47706f344 Sema: validate packed struct field types 2022-08-01 23:59:40 +03:00
Veikka Tuominen
57f9405a8f Sema: validate bitcast operand type 2022-08-01 23:37:01 +03:00
Veikka Tuominen
4758752e5d Sema: implement coercion from tuples to tuples
Closes #12242
2022-07-30 00:18:08 +03:00
Veikka Tuominen
f43ea43ac9 stage2: fix hashing of struct values
Closes #12279
2022-07-30 00:17:49 +03:00
joachimschmidt557
0fc79d602b stage2 ARM: more support for switch statements 2022-07-28 20:44:32 +00:00
Andrew Kelley
3ba7098a17 LLVM: fix returning extern union with C callconv 2022-07-27 17:56:15 -07:00
Andrew Kelley
6a4df2778e AstGen: fix ref instruction injection for functions
For the expressions regarding return type, alignment,
parameter type, etc.
2022-07-27 16:19:23 -07:00
Andrew Kelley
f880af369d LLVM: fix lowering byte-aligned packed struct field pointers 2022-07-27 16:19:23 -07:00
Evan Haas
7ba1f9bfb5 translate-c: take address of functions before passing them to @ptrToInt
Fixes #12194
2022-07-27 14:03:08 +03:00
Andrew Kelley
a2ab9e36fa
Merge pull request #12143 from Vexu/stage2-safety
Stage2 runtime safety progress
2022-07-23 20:09:24 -07:00
Andrew Kelley
9964324856 disable flaky behavior test
see #12208
2022-07-23 20:03:50 -07:00
Veikka Tuominen
baf516218e Sema: don't add union field access safety check for single field unions 2022-07-23 15:40:12 +03:00
Veikka Tuominen
711b656773 Sema: @floatToInt safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen
ff7ec4efb5 Sema: bad union field access safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen
55fe34100f Sema: exact division safety 2022-07-23 15:40:11 +03:00
Andrew Kelley
f591936480
Merge pull request #12198 from Vexu/stage2
Sema: fix loading and storing of optional pointers represented as pointers
2022-07-22 20:47:40 -07:00
Andrew Kelley
5dd59a5423
Merge pull request #12191 from ziglang/underaligned-fields
LLVM: fix lowering of structs with underaligned fields
2022-07-22 11:58:50 -07:00
Veikka Tuominen
03b1fbe50d stage2: fix airIsErr when is_ptr == true 2022-07-22 21:07:55 +03:00
Veikka Tuominen
1f748fe426 Sema: fix mutation of optional ptr represented as regular ptr 2022-07-22 19:50:11 +03:00
Veikka Tuominen
c619371ec1 Sema: fix loading and storing of optional pointers represented as pointers 2022-07-22 17:03:42 +03:00
Andrew Kelley
f550c29c4e LLVM: fix lowering of structs with underaligned fields
When lowering a struct type to an LLVM struct type, keep track of
whether there are any underaligned fields. If so, then make it a packed
llvm struct. This works because we already insert manual padding bytes
regardless.

We could unconditionally use an LLVM packed struct; the reason we bother
checking for underaligned fields is that it is a conservative choice, in
case LLVM handles packed structs less optimally. A future improvement
could simplify this code by unconditionally using packed LLVM structs
and then make sure measure perf is unaffected.

closes #12190
2022-07-21 22:51:17 -07:00
Veikka Tuominen
794beafb9c Sema: validate extern struct field types earlier
`validateExternType` does not require the type to be resolved so we can
check it earlier. Only doing it in `resolveTypeFully` lead to worse or
missing compile errors.
2022-07-21 12:21:30 -07:00
Veikka Tuominen
d851b24180 Sema: validate function pointer alignment 2022-07-21 12:21:30 -07:00
Veikka Tuominen
62120e3d0e Sema: fix non-exhaustive union switch checks 2022-07-21 12:21:30 -07:00
Andrew Kelley
5b7e332b28 disable new behavior test in stage1
I regressed this in 379beceffd1b0a0b0d8f3163dc02eba1e53ffa39; sorry
about that.
2022-07-20 16:17:33 -07:00
Andrew Kelley
379beceffd improve test case from previous commit
Now it checks that the code is correctly compiled rather than only checking
that it does not crash the compiler.
2022-07-20 15:21:24 -07:00
Veikka Tuominen
d41dd499a9 stage2 llvm: fix handling of pointer fields in packed structs 2022-07-20 17:07:12 +03:00
Andrew Kelley
0efc6a35be Sema: fix enum value without tag name used as switch item
Previously stage2 would report a false positive compile error saying there
was no tag for this value.
2022-07-19 18:39:48 -07:00
Andrew Kelley
1d5f865cfa Sema: fix runtime instructions omitted
in the presence of comptime control flow.

fixes #12171
2022-07-19 17:45:38 -07:00
Andrew Kelley
04572f6e34 Sema: fix coerceResultPtr
It did not handle properly when the dummy operand was a comptime_int; it
was crashing in coerce because comptime_int is supposed to be
comptime-known. So when calling coerceResultPtr, we pass the actual
operand, not a dummy operand, which means it will have the proper
comptime value when necessary.
2022-07-14 18:11:46 -07:00
Andrew Kelley
667ad9250f Sema: fix coerce_result_ptr in case of inferred result type
Previously, the logic for analyzing coerce_result_ptr would generate
invalid bitcast instructions which did not include coercion logic, such
as optional wrapping, resulting in miscompilations.

Now, the logic of resolve_inferred_alloc goes back over all the
placeholders inserted by coerce_result_ptr, and replaces them with logic
doing the proper coercions.

Closes #12045
2022-07-14 16:48:44 -07:00
Andrew Kelley
1653a9b259
Merge pull request #12098 from ziglang/llvm-riscv64
LLVM: implement signext/zeroext attributes
2022-07-13 19:15:19 -04:00
Andrew Kelley
fad95741db AstGen: fix loop control flow applying to wrong loop
In the case of 'continue' or 'break' inside the 'else' block of a
'while' or 'for' loop.

Closes #12109
2022-07-13 16:10:41 -07:00
Andrew Kelley
35e7011124 LLVM: implement signext/zeroext attributes
For calling convention ABI purposes, integer attributes and return
values need to have an LLVM attribute signext or zeroext added
sometimes. This commit implements that logic.

It also implements a proof-of-concept of moving the F16T type from
being a compiler_rt hack to being how the compiler lowers f16 in
functions that need to match certain calling conventions.

Closes #12054
2022-07-13 11:14:46 -07:00
Andrew Kelley
4a28c1d5c3 stage2: lower each struct field type, align, init separately
Previously, struct types, alignment values, and initialization
expressions were all lowered into the same ZIR body, which caused false
positive "depends on itself" errors when the initialization expression
depended on the size of the struct.

This also uses ResultLoc.coerced_ty for struct field alignment and
initialization values. The resulting ZIR encoding ends up being roughly
the same, neither smaller nor larger than previously.

Closes #12029
2022-07-13 02:38:13 -04:00
Veikka Tuominen
122c76a167 Sema: allow void as an extern union field & fix invalid extern unions 2022-07-11 20:30:16 +03:00
Cody Tapscott
d182e2ebda stage1: Lower libcalls on Windows x86-64 correctly
This change is the Zig counterpart to https://reviews.llvm.org/D110413

Since we lower some libcalls directly (just like clang does), we need to
make sure that the ABI we call with matches the ABI of the compiler-rt
we are providing (and also the ABI expected by LLVM).

While I was at it, I noticed some flawed vector handling in the binary
soft float ops in stage 1, so I shored up the logic a bit and expanded
an existing test to cover the missing functionality.
2022-07-10 20:52:28 -07:00
Andrew Kelley
b88151e0e1
Merge pull request #12001 from ziglang/llvm14
Upgrade to LLVM 14
2022-07-10 03:06:05 -04:00
Andrew Kelley
e0d5ae75af these riscv64 behavior tests work for stage1 but not stage2 2022-07-09 12:48:59 -07:00