1031 Commits

Author SHA1 Message Date
Andrew Kelley
011663eea5 Merge remote-tracking branch 'origin/master' into llvm15 2022-09-12 16:11:18 -07:00
Andrew Kelley
01e89fec71 disable LLVM 15 regressed behavior test: "vector @splat"
See #12827
2022-09-12 16:02:31 -07:00
Veikka Tuominen
e323cf1264 stage2: change how defers are stored in Zir
Storing defers this way has the benefits that the defer doesn't get
analyzed multiple times in AstGen, it takes up less space, and it
makes Sema aware of defers allowing for 'unreachable else prong'
error on error sets in generic code.

The disadvantage is that it is a bit more complex and errdefers with
payloads now emit a placeholder instruction (but those are rare).

Sema.zig before:
  Total ZIR bytes:    3.7794370651245117MiB
  Instructions:       238996 (2.051319122314453MiB)
  String Table Bytes: 89.2802734375KiB
  Extra Data Items:   430144 (1.640869140625MiB)
Sema.zig after:
  Total ZIR bytes:    3.3344192504882812MiB
  Instructions:       211829 (1.8181428909301758MiB)
  String Table Bytes: 89.2802734375KiB
  Extra Data Items:   374611 (1.4290275573730469MiB)
2022-09-12 01:52:44 -04:00
Andrew Kelley
ab3ac291ac Merge remote-tracking branch 'origin/master' into llvm15 2022-09-11 20:26:53 -07:00
Jakub Konka
4fd4c733d4 x86_64: pass more behavior tests 2022-09-10 09:23:26 +02:00
Jakub Konka
5778077f9f
Merge pull request #12799 from joachimschmidt557/stage2-arm
stage2 ARM: introduce allocRegs mechanism and other improvements
2022-09-10 09:13:08 +02:00
Jacob Young
5b9c5191ab type: print comptime on fn type params
This avoids the following confusing error message:

    error: expected type 'fn(i32, i32) void', found 'fn(i32, i32) void'
2022-09-10 01:55:52 +03:00
Evan Haas
8e631ee3e7 translate-c: Escape non-ASCII characters that appear in macros
Macro definitions are simply a slice of bytes, which may not be
UTF-8 encoded. If they are not UTF-8 encoded, escape non-printable
and non-ASCII characters as `\xNN`.

Fixes #12784
2022-09-10 01:50:17 +03:00
joachimschmidt557
94499898e5
stage2 ARM: implement basic array_elem_val 2022-09-09 20:26:04 +02:00
Andrew Kelley
37cdb5dbf9 Merge remote-tracking branch 'origin/master' into llvm15 2022-09-09 10:26:17 -07:00
joachimschmidt557
b976997e16
stage2 ARM: implement ptr_elem_val 2022-09-09 19:17:18 +02:00
joachimschmidt557
a0a7d15142
stage2 ARM: support larger function stacks
This is done by introducing a new Mir pseudo-instruction
2022-09-09 19:17:18 +02:00
joachimschmidt557
3794f2c493
stage2 ARM: implement struct_field_val for registers 2022-09-09 19:17:18 +02:00
joachimschmidt557
261fec8036
stage2 ARM: amend implementation of various AIR instructions
- unwrap_errunion_err for registers
- unwrap_errunion_payload for registers
- ptr_slice_len_ptr for all MCValues
- ptr_slice_ptr_ptr for all MCValues
2022-09-09 19:17:17 +02:00
joachimschmidt557
e2b029e2c8
stage2 ARM: implement field_parent_ptr 2022-09-09 19:17:17 +02:00
Veikka Tuominen
c7e45aebaf llvm: handle pointers in packed structs in more places
Closes #12776
2022-09-08 12:51:40 +03:00
Veikka Tuominen
37afab2add Sema: preserve alignment of const decl pointers
Closes #12769
2022-09-08 00:37:11 +03:00
Evan Haas
e283a40d17 translate-c: convert tabs to \t in object-like macro string literals
Closes #12549
2022-09-07 14:46:58 +03:00
Andrew Kelley
b7900de168 Merge remote-tracking branch 'origin/master' into llvm15 2022-09-06 19:45:02 -07:00
riChar
349cf54b32
llvm: fix the type parameter of GlobalAlias
Closes 12680
2022-09-04 18:44:45 +03:00
Veikka Tuominen
f281f3d10e Sema: improve behavior of comptime_int backed enums 2022-09-02 17:57:11 +03:00
Veikka Tuominen
8b58dab78b Sema: resolve lazy value before intToFloat
Closes #12698
2022-09-02 17:57:10 +03:00
Veikka Tuominen
7a8d9af4a9 stage2 llvm: correct handling of zero-bit types in unionFieldPtr
Pointers to zero-bit types are not zero-bit types so the function should
return something.
Closes #12716
2022-09-02 17:57:10 +03:00
Veikka Tuominen
4462d08224 stage2 llvm: fix passing packed structs to callconv(.C) functions
Closes #12704
2022-09-02 17:57:10 +03:00
Veikka Tuominen
26e9839132 disable test for non-llvm backends
Follow up to fdb88708527742e450e4c566024d9d50ce61dd8d
2022-08-31 16:46:51 +03:00
Evan Haas
fdb8870852 translate-c: promote large integer macros to unsigned long long if necessary
Closes #10793

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-31 15:52:53 +03:00
Andrew Kelley
1e21876de2 Merge remote-tracking branch 'origin/master' into llvm15 2022-08-30 13:02:43 -07:00
Andrew Kelley
7377dce368 avoid exposing supportsTailCall in the standard library
This is problematic because in practice it depends on whether the
compiler backend supports it too, as evidenced by the TODO comment about
LLVM not supporting some architectures that in fact do support tail
calls.

Instead this logic is organized strategically in src/target.zig, part of
the internal compiler source code, and the behavior tests in question
duplicate some logic for deciding whether to proceed with the test.

The proper place to expose this flag is in `@import("builtin")` - the
generated source file - so that third party compilers can advertise
whether they support tail calls.
2022-08-30 12:50:15 -07:00
Veikka Tuominen
65d3723968 Sema: check that target supports tail calls 2022-08-30 12:22:07 -07:00
Veikka Tuominen
c558de6655 stage2 llvm: use tag value instead of field index in airUnionInit
Closes #12656
2022-08-30 12:22:07 -07:00
Veikka Tuominen
67a44211f7 Sema: improve handling of always_tail call modifier
Closes #4301
Closes #5692
Closes #6281
Closes #10786
Closes #11149
Closes #11776
2022-08-30 12:22:07 -07:00
Andrew Kelley
1cb8065a52 skip new behavior tests that do not pass for stage1 2022-08-29 22:58:24 -07:00
Andrew Kelley
3c506c8aaa disable tests failing due to LLVM 15 regressions 2022-08-29 22:58:24 -07:00
Andrew Kelley
d2d42cf7ba
Merge pull request #12641 from Luukdegram/wasm-c-types
stage2: fix size of c_longdouble for Wasm target
2022-08-29 18:21:38 -04:00
Luuk de Gram
1eb22e7ad6
wasm: skip unimplemented behavior test
Since now the size of a c_longdouble is correctly 16 bytes,
the test is no longer passing. It was previously accidentally passing
due to incorrect sizing and it not being larger than the size
of a f64.

disable long_double test for windows
2022-08-28 17:50:07 +02:00
Veikka Tuominen
15cc4514e0 Sema: add missing calls to resolveStructLayout
Closes #12645
2022-08-28 15:41:21 +03:00
Veikka Tuominen
e2dc77ab62 Sema: correct one possible value for tuples
Closes #12376
2022-08-28 15:41:21 +03:00
Veikka Tuominen
776caaf999 Sema: fix handling of non-standard int types in empty non-exhaustive enums
Closes #12649
2022-08-28 15:41:21 +03:00
antlilja
ae8d26a6a0 Sema: add error for non-comptime param in comptime func
Adds error for taking a non comptime parameter in a function returning a
comptime-only type but not when that type is dependent on a parameter.

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-27 11:17:48 +03:00
David Gonzalez Martin
da95da438e Add behavior test coverage for nested packed struct field access
Closes #3091
2022-08-26 21:43:38 -04:00
martinhath
3fa5415253
Sema: ensure resolveTypeFields is called for optional and error union types
We call `sema.resolveTypeFields` in order to get the fields of structs
and unions inserted into their data structures. If it isn't called, it
can happen that the fields of a type is queried before those fields are
inserted into (for instance) `Module.Union.fields`, which would result in
a wrong 'no field named' error.

Fixes: #12486
2022-08-26 11:37:17 +03:00
David Gonzalez Martin
d6bb9af18d stage2: Reference to void constants
Closes #7567
2022-08-26 00:00:22 -04:00
Andrew Kelley
d2ad8afff4 LLVM: fix missing alignment on wrapping instructions
Previously, when lowering AIR instructions `wrap_errunion_payload`,
`wrap_errunion_err`, and `wrap_optional`, the LLVM backend would create
an alloca instruction to store the result, but did not set the alignment
on it. This caused UB which went undetected for a long time until we
started enabling the stack protector.

Closes #12594
Unblocks #12508
Inspires #12634

Tests passed locally:
 * test-behavior
 * test-cases
2022-08-25 16:15:48 -07:00
Veikka Tuominen
4405188cf7 Sema: ignore comptime params in partial func type check
This fixes a bug exposed by cd1833044ab7505bc101c85f59889bd3ea3fac80
where a function type would be converted to generic_poison even after
being instantiated due to containing comptime only types.

This could also be fixed by just checking `is_generic_instantiation`
but this way also provides better type names.

Closes #12625
2022-08-25 16:29:23 +03:00
Andrew Kelley
7453f56e67 stage2: explicitly tagged enums no longer have one possible value
Previously, Zig had inconsistent semantics for an enum like this:

`enum(u8){zero = 0}`

Although in theory this can only hold one possible value, the tag
`zero`, Zig no longer will treat the type this way. It will do loads and
stores, as if the type has runtime bits.

Closes #12619

Tests passed locally:
 * test-behavior
 * test-cases
2022-08-24 22:20:31 -07:00
Andrew Kelley
7a881435ed
Merge pull request #12623 from Vexu/stage2-fixes
Stage2 fixes
2022-08-24 15:59:46 -04:00
Andrew Kelley
2a96209c40
Merge pull request #12574 from Vexu/remove-bit-op-type-param
stage2+stage1: remove type parameter from bit builtins
2022-08-24 15:57:44 -04:00
Veikka Tuominen
f49dff64c6 Sema: check one possible value earlier in zirValidateArrayInit
Closes #12566
2022-08-24 21:31:02 +03:00
Veikka Tuominen
cd1833044a Sema: do not construct nested partial function types
Closes #12616
2022-08-24 21:31:02 +03:00
Jakub Konka
abfe21a4fe skip failing f80 behavior tests on Windows 2022-08-23 22:43:19 +02:00