Commit Graph
133 Commits
Author SHA1 Message Date
Jeroen van Rijn 00a03e72b5 Merge pull request #7400 from kalsprite/union_slice_assert
backend: only reuse a compound literal's storage for a variable of its type
2026-08-20 03:38:09 +02:00
korvahkh 02246ac6fd Implement fixes for constant unions
Note that with this commit, casting through
multiply-nested unions is forbidden, e.g.
```
U :: union {int, V}
V :: union {bool}
x: U = true
```
does not compile.
(Previously the compiler would simply crash)

This is to avoid situations where adding variants
can lead to unexpected changes in the value.

For example if `U` is changed to have a `bool`
variant of its own:
```
U :: union {int, bool, V}
```
Then `x: U = true` would equal
`U(true)` instead of `U(V(true))`.

Single-variant unions are exempt, primarily to
improve the ergonomics of `Maybe` in cases like:
```
x: Maybe(union{int, bool}) = 1
```

Fix #6100
Fix #6699
Fix #6895
Fix #6896
Fix #6897
Fix #7036
Fix #7083
Fix #7091
2026-08-19 20:12:56 -05:00
kalsprite bc2649bacd backend: only reuse a compound literal's storage for a variable of its type 2026-08-19 17:53:34 -07:00
kalsprite 0ef3d96724 fix reinterpretation on riscv 2026-08-17 21:53:37 -07:00
Jeroen van Rijn 5787cbc68b Fix backend support for #unroll on [dynamic]T 2026-08-15 21:34:58 +02:00
kalsprite 0dbd55168f hoist if stmt 2026-08-11 22:25:44 -07:00
corley 87912a8b88 fixes range loop over array elements in soa containers 2026-08-11 03:20:13 +03:00
corley 7b45adf8e9 fixes swizzling for array elements in soa arrays/slices 2026-08-09 03:17:04 +03:00
bingis-khan c1e327c566 Fix LLVM codegen for matching on nil for union{} 2026-07-26 11:11:36 +02:00
gingerBill 8d1d126e16 Rearrange context and value_type values of lb_const_value 2026-06-05 10:19:55 +01:00
gingerBill 1744f57d01 Use permanent_alloc_item directly rather than through the gb_alloc_item generic interface 2026-03-16 16:03:27 +00:00
gingerBill ef36a18323 Enable some RVO by default 2026-03-16 14:52:07 +00:00
gingerBill 93852df29e Support #unroll(N) for for FCD arrays 2026-03-16 12:28:18 +00:00
gingerBill e87564b205 Support for in for FCD arrays 2026-03-16 12:21:41 +00:00
gingerBill 5fa274cb6a -internal-rvo 2026-03-15 22:10:03 +00:00
gingerBill 5d165f70e1 Add loads of RVO optimizations for basic 1-value return cases 2026-03-15 21:53:38 +00:00
gingerBill bb2e42faa6 More uses of SSA aggregation values 2026-03-15 19:49:26 +00:00
gingerBill 70dd93db8f Correct case nil: handling for unions 2026-03-15 17:24:38 +00:00
gingerBill 8cb7965aa5 for init; x in y {} style loops 2026-02-11 15:33:14 +00:00
gingerBill 63c4faca75 Fix positions for debug locations in defer, loops, and switch clauses 2026-02-02 11:19:00 +00:00
gingerBill 37c2f68824 Allow #unroll for arrays of fixed length which are not constants 2026-01-28 15:30:23 +00:00
gingerBill f1c6c52c21 Fix @(static, rodata) for slices 2025-12-30 12:58:37 +00:00
gingerBill 39fa1b7201 LLVM IR: Improve basic block names for trivial switch statements for debuggability 2025-12-28 11:52:31 +00:00
gingerBill 14a60adefe LLVM IR: Improve type switch case names for better debuggability when generating LLVM IR 2025-12-27 12:48:25 +00:00
Laytan c4d1cd6ee5 fixes for 32bit with regards to typeid 2025-11-04 21:37:29 +01:00
gingerBill 6bca1475ed Convert procedures_to_generate to a queue 2025-09-19 14:15:25 +01:00
gingerBill 1e0902677f Multithread min dep set by removing the set itself 2025-09-10 17:29:11 +01:00
gingerBill bb4bc316a4 for in string16; Support string16 across core 2025-08-02 12:20:35 +01:00
Laytan Laats f94fc992d7 fix swizzle in for in statement
Fixes #1730
2025-06-02 20:30:48 +02:00
Laytan Laats c35a45e823 fix global and static any
Fixes #4627
2025-05-17 16:49:30 +02:00
tf2spi 2f636886a5 Add debug info for labels (#4385)
* Emit label debug info w/o location

* Insert debug label call

* Slight refactor for later fix

* Improve debug labels for block statements

* Improve debug info with for loops

* Generate label lbBlocks w/ debug

* Lightly refactor lb_add_debug_label

* Revise comments, add null check assertion

* Use LLVM-C API for debug labels

* Prefer C DILabel API for POSIX, fallback to CPP

* Use version check for LLVM-C DILabel
2025-05-15 22:11:06 +02:00
Lucas Perlind 46e0c7ad74 Cleanup 2025-05-07 11:30:58 +10:00
Lucas Perlind 83bc2d3c4a Add asan support for various allocators 2025-05-06 14:55:50 +10:00
Barinzaya 9284ebb5e8 Add missing cast to global/static var alignments. 2025-04-24 14:35:00 -04:00
Barinzaya b41a776027 Correctly align global and static variables.
This can be important if matrices or SIMD vectors are being used in
global or static variables, as otherwise it may result in crashes due to
aligned instructions accessing misaligned variables.
2025-04-24 14:21:21 -04:00
gingerBill fe040d1bbd Propagate @(link_section=<string>) to nested declarations 2025-04-08 11:36:53 +01:00
gingerBill 168a41ba2c Fix #4803 2025-03-07 10:33:41 +00:00
Barinzaya ef83f2115a Implemented #reverse for for in bit_set. 2025-03-02 16:24:18 -05:00
Barinzaya 36d5e09419 Re-implemented for on bit_sets to use CTZ.
This solution is both faster at run-time and a simpler implementation
than the original solution, which required separate cases for enums and
ranges.
2025-02-28 06:51:14 -05:00
gingerBill 46a8991d0f Canonicalize generated procedures 2025-02-24 14:19:02 +00:00
gingerBill 99d91ccd31 Work on making name mangling deterministic 2025-02-17 11:32:49 +00:00
gingerBill 328d893cb5 #unroll(N) for 2025-01-10 12:22:18 +00:00
gingerBill 7b334d2bd9 Add #branch_location 2025-01-01 17:26:15 +00:00
Laytan Laats fa39d87f88 properly keep track of current scope for debugging
Fixes #4519
2024-11-27 20:55:48 +01:00
bobsayshilol e67692b066 Avoid member access through nullptr in debug
If |result_count| is 0 then |results| will be a nullptr and hence the
access |results->Tuple| is undefined behaviour. There's already an
early return in the 0 branch so move that to be the first thing so that
we can guarantee that it's not a nullptr.

Note that technically we take the address of the result so it's not
actually dereferencing it, however UBSan doesn't care about that.
2024-10-27 22:02:34 +00:00
Laytan Laats da1e09c95d check packed load and set alignment on all loads, not just lb_emit_load 2024-10-25 15:23:15 +02:00
Laytan 722b638e2c "fix" #4169, looks like llvm 14 bug 2024-08-31 19:40:05 +02:00
gingerBill 476030dd28 Fix #4156 2024-08-31 13:51:35 +01:00
gingerBill 2a0785037b Fix switch val in ptr 2024-08-19 12:19:45 +01:00
gingerBill 95c3b8a8de Move assert to else branch 2024-08-18 22:45:26 +01:00