Commit Graph
144 Commits
Author SHA1 Message Date
Jeroen van Rijn 3500b228f9 Merge pull request #7740 from bplu4t2f/test-7689
Fix #7689 - Incorrect debug source location at the end of if/else chains
2026-10-05 02:26:51 -07:00
bplu4t2f 854cd0e8d8 Fix #7689 - set debug source location of if/else "done" jump to end of the respective block 2026-10-04 14:54:00 +02:00
gingerBill bdb0364739 Remove the missing procedures fallback from the backend: the checker adds the Objective-C runtime procedures the backend calls, local foreign procedures with a duplicate name are bound to the existing declaration, and local procedures passed to a $ parameter are created up front 2026-10-03 22:26:08 +01:00
gingerBill 29106aaa1e Cache type layouts and union constantability, build nested constants once, create debug files lazily 2026-10-03 01:26:01 +01:00
gingerBill c628768c5e Strip constant parameters from specialized procedure types; fix calling a parenthesized polymorphic callee 2026-10-02 23:11:13 +01:00
gingerBill 38fa57e907 Make global checking and codegen order-independent 2026-10-01 15:01:14 +01:00
corleypc 6c5651638c Merge branch 'master' into lifetime-markers 2026-09-29 16:04:59 +03:00
gingerBill f3ab1d4b3c Merge pull request #7639 from louisnovy/fix-array-programming-with-matrices
Fix #6302: broadcasting arrays of matrices and matrices
2026-09-29 13:05:33 +01:00
alyekypo b9c4067f78 fix(llvm): emit union constants for non-constantable unions
`constant: U : value` produced a constant of the wrong type:
lb_const_value took its union-lowering branch only when
`is_type_union_constantable(type)` held, so for a union with a variant
that whitelist rejects (`union{bool, ^int}`) the value fell through to
the scalar branch and reached `LLVMConstInt(lb_type(m, union_type),
...)`.  The constant emitted there does not match the union's type:
bytes that change between runs for `true`, a compiler crash for `1.0`,
an `is_type_string` assertion for a string literal.

The checker already resolves which variant a constant represents and
records it in `ExactValue::variant_type` - the variant type, tag index,
payload and padding the union branch needs - so that branch is now also
taken when the value pins a variant this backend can build as a
constant.  The type-level whitelist was re-guessing information the
value already carries; variant types this backend cannot build as
constants (`any`) stay excluded.

lb_build_static_variables had the same defect in another place: it
lowered an initializer with the expression's type instead of the
declared type, so `@(static) s: U` emitted a payload-only constant and
LLVM rejected the module with “Global variable initializer type does not
match global variable type!”.  It now passes the declared type and gives
the global the constant's layout-compatible type, the way the file-scope
path already does.

Blast radius: every union-typed constant, i.e. typed constants, global
static initializers, @(static)/@(thread_local)/@(rodata), default
parameters and constant aggregate elements.  Unions whose variants are
all constantable keep the previous path.
2026-09-28 19:32:04 +00:00
Louis Novy 9453e0e75e Fix broadcasting arrays of matrices and matrices 2026-09-26 19:39:53 -04:00
corley bac6130710 lifetime markers for named locals 2026-09-20 15:55:26 +03:00
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