Commit Graph
7406 Commits
Author SHA1 Message Date
gingerBill 80f640c18d Fix cond_wait synchronizing on the condition variable; match objects within each other; mark more Win32 waits 2026-10-08 23:14:14 +01:00
gingerBill 3c7034c158 Add @(synchronizes) to channels; Model guards deferred unlocks when inferring 2026-10-08 23:05:45 +01:00
gingerBill 4508144727 Add @(synchronizes_shared=...) for shared locks; Infer @(synchronizes) for wrappers 2026-10-08 22:56:54 +01:00
gingerBill 5de6a99129 Add @(synchronizes=<Enum>); Vet plain writes; Warn on mixed-sized atomics; Count fences in callers and other branches 2026-10-08 17:16:09 +01:00
gingerBill 68bb5200b4 Warn on atomics on an unshared @(thread_local), and on stores followed by loads which only .Seq_Cst orders 2026-10-08 16:38:37 +01:00
gingerBill 5a90cc5c82 Count fences within called procedures; reject atomic writes to @(rodata) 2026-10-08 16:27:18 +01:00
gingerBill 1a136c13bd Merge pull request #7824 from MatzeOGH/debug-info-string
Fix the debug info for indirect parameters that get a callee copy
2026-10-08 16:12:23 +01:00
gingerBill eea3caecc1 Merge pull request #7825 from bbodi/fix/llvm-backend-bugs
Fix/llvm backend bugs
2026-10-08 16:12:09 +01:00
bbodi 8dbbbd2d64 Fix -debug when every initial file is excluded
The debug compile unit was made from the first file of the initial
package. When build tags exclude all of its files, as for the
Windows-only tests/issues/test_issue_7547.odin on other targets, there
is none, and `odin test -debug` crashed on an out-of-bounds index.
Without `-debug` such a test builds and reports that there are no
tests to run, which `tests/issues/run.sh` relies on.

Fall back to the package's path for the compile unit's file.
2026-10-08 15:51:24 +02:00
bbodi d65a9ba9bc Keep disabled procedures whose value is taken
A procedure with `@(disabled=true)` adds no dependency where it is
used, so that the calls to it, which are removed, do not pull it in.
Taking its value, e.g. `rawptr(assert)` with `-disable-assert`, then
referenced a procedure that was never generated, and LLVM asserted
"missing procedure 'assert'".

Add the dependency for every use that is not the callee of a call.
2026-10-08 15:51:24 +02:00
bbodi 9f62e02634 Reject casts of unspecialized polymorphic procs
Casting a polymorphic procedure to `rawptr`, or to a procedure type
it cannot be specialized to, was accepted. There is no procedure to
take the address of, so the value came out nil, or the build hung, as
with `x := rawptr(avl.init_cmp)`. Assigning one to `rawptr` already
errors; make `cast` and `transmute` match. Casting to a procedure type
that specializes it still works, as assignment does.
2026-10-08 15:51:24 +02:00
bbodi 1448ac3494 Hash all bytes of string16 and cstring16 map keys
Map keys of type `string16` used `default_hasher_string`, which reads
the length as a byte count; for a `string16` it counts u16 units, so
only the first half of the key was hashed. `cstring16` keys took the
same path and were read as a pointer and a length, which crashes.

Add `default_hasher_string16` and `default_hasher_cstring16` to the
runtime and use them for the generated key hashers, which are also
what the runtime and `intrinsics.type_hasher_proc` use.
2026-10-08 15:51:24 +02:00
bbodi c0e78fc172 Bounds check constant slices of [dynamic; N]T
Slicing a `[dynamic; N]T` skipped the bounds check when both indices
were constant, as is done for fixed arrays. But its length is only
known at runtime, so `a[0:3]` with a length of 2 silently returned
stale elements. Always check against the length, as for `[dynamic]T`.
2026-10-08 15:51:24 +02:00
bbodi ed6b1dd5cd Describe rawptr as a pointer to no type
`rawptr` pointed to a 1-byte `void` base type, so gdb printed every
rawptr, such as an allocator's `data`, as a C string. Describe it as a
pointer with no pointee type, which is how clang emits `void *`. This
also drops the address space it was given by mistake.
2026-10-08 15:32:26 +02:00
bbodi e3c69ec540 Fix the debug name and characters of cstring16
The name `cstring16` was passed with the length of `cstring`, so the
type was named `cstring`. Its characters, and those of `string16`,
were a 16-bit `wchar_t`, which gdb reads as UTF-32 on Linux and so
printed as garbage. On DWARF describe them as `char16_t`, a 16-bit UTF
character, which gdb reads as UTF-16. CodeView keeps `wchar_t`.
2026-10-08 15:31:11 +02:00
bbodi 243fb9184f Define enum, typeid and #soa debug types locally
With the split debug types modules, every other module only declares a
record type. gdb resolves a declared struct by searching for its
definition, but a declared enum by taking the first symbol of that name,
which is the declaration itself in the module being looked at. Enums,
flag enum bit_sets and typeid showed as <incomplete type>, and every
`any` printed as nil since its `id` could not be read. gdb also cannot
find a declared type whose name starts with `#`, so #soa types were
incomplete too.

On DWARF, define these in every module that uses them, as clang does
with enums. CodeView resolves forward references by name, so Windows
keeps them in the types modules.
2026-10-08 15:29:58 +02:00
bbodi 3bd72688aa Fix multi-value calls in matrix and #simd literals
The checker lets a multi-value call fill several elements of a matrix
or #simd literal, as it does for arrays, but the constant part of the
literal was built as if each element were one value. A matrix literal
like `matrix[2,2]f32{three(), 4}` hit an assertion, and a #simd
literal put the constants after the call in the wrong lanes.

Skip over the values of a call when placing the constants, as the
array case already does.
2026-10-08 15:12:18 +02:00
gingerBill 0e9f930983 Merge pull request #7823 from odin-lang/bill/debug-info
Debug Info Improvements
2026-10-08 13:55:21 +01:00
gingerBill 6bc36986d2 Keep the names of big endian types in CodeView and add RAD views to swap their bytes 2026-10-08 13:41:52 +01:00
Matthias Huerbe 6fb0d77cdb Fix the debug info for indirect parameters that get a callee copy 2026-10-08 14:20:11 +02:00
gingerBill 4d8e8aaf4a Mark optimized procedures, add assignment tracking, and add MD5 file checksums on LLVM 22+ 2026-10-08 12:28:21 +01:00
gingerBill 8109f1a401 Copy the lldb pretty printers into the .dSYM of macOS binaries built with -debug where lldb loads them from 2026-10-08 12:04:16 +01:00
gingerBill f689471c90 Embed the gdb pretty printers in the .debug_gdb_scripts section of ELF binaries built with -debug, and move the script next to the runtime it reads 2026-10-08 11:54:08 +01:00
gingerBill d0a5d4a8e2 Fix #7820: keep only the origins of what a call's flow loads from memory of an unknown type in the escape analysis 2026-10-08 11:14:39 +01:00
gingerBill 81842d44dc Improve RAD Debugger view information for unions, string16, and anything else need to be generated 2026-10-08 11:09:33 +01:00
gingerBill 535132a22e Add @(futex_parameter="name") 2026-10-08 10:46:58 +01:00
gingerBill 29f4b033df Describe bit_sets as flag enums on DWARF and typeid as an enum of the type table defined once alongside any, declare the element of #soa range loops 2026-10-08 10:42:43 +01:00
gingerBill 7b312ac696 Check for invalid enum kind cases with the atomic reporting 2026-10-08 10:29:26 +01:00
gingerBill 702533c4ef Warn on volatile accesses of what is accessed atomically, as a volatile access is not atomic 2026-10-08 10:23:44 +01:00
gingerBill 399b6d4a36 Name procedures and globals in debug info by package and enclosing procedure, with literals named by line, one shared name for all polymorphic instances, and exported and custom link names kept 2026-10-08 10:10:15 +01:00
gingerBill 9db7f49441 Warn on atomics on a local whose address is only taken by them, suggesting volatile_load/volatile_store 2026-10-08 10:09:06 +01:00
gingerBill 216bcf7475 Split the debug types module into eight picked by a hash of each type's name, defined in parallel rounds and anchored by a union of pointers to its types 2026-10-08 09:48:40 +01:00
gingerBill 8dee146bf3 Warn on weak compare-exchanges whose success is ignored, futexes woken before they are written, and signal fences where a thread fence would pair; reject atomics on what may be misaligned for them 2026-10-08 09:46:14 +01:00
gingerBill 91ec3aa76b Make atomic fences only order what they may be reached after (or before), including through calls to the procedures with the relaxed accesses 2026-10-08 09:20:26 +01:00
gingerBill 0a4724602b Define record debug types once in a debug types module with forward declarations in every other module 2026-10-08 09:18:15 +01:00
gingerBill 8c692ad0e9 Give debug types unique identifiers, describe self-referencing procedure types per debug format, declare range loop variables once, and use DWARF 5 on Darwin and Linux 2026-10-08 08:56:39 +01:00
gingerBill 6cfa3dafb7 Finalize debug info per module in parallel, and skip debug info work that was never used 2026-10-08 01:05:24 +01:00
gingerBill 35fdd3c499 Fix infinite recursion lowering procedure types that contain themselves 2026-10-08 00:26:40 +01:00
gingerBill b0c36ab7ca Merge pull request #7816 from odin-lang/bill/atomic-memory-ordering-pass
Atomic Memory Ordering and Futex Operation Passes
2026-10-07 23:36:22 +01:00
gingerBill ecedcbc0bf Add @(futex=.Wait) and @(futex=.Wake) with intrinsics.Futex_Operation, so the atomic analysis checks futex words, and use relaxed ordering for Atomic_Cond's counter 2026-10-07 23:18:02 +01:00
gingerBill bb9f0a2c47 Prefix the atomic analysis procedures with check_atomic_ 2026-10-07 22:54:59 +01:00
gingerBill 158d0a9d8d Replace the #+escape-analysis/#+atomic-analysis file tags with #+analysis which takes names and ! like #+vet 2026-10-07 22:50:20 +01:00
gingerBill b12195bebf Add an atomic memory ordering analysis (-no-atomic-analysis, #+atomic-analysis, #+no-atomic-analysis) warning where release or acquire ordering pairs with nothing, and -vet-atomic-access for plain reads of what is accessed atomically 2026-10-07 22:43:08 +01:00
gingerBill 42ce435053 Merge pull request #7814 from BigBoyBarney/vet-help
Update -vet flag help message
2026-10-07 22:12:56 +01:00
gingerBill 711f08a641 Make is_type_lock_free follow what each target lowers without library calls, and reject atomics on types which are not lock-free 2026-10-07 21:58:32 +01:00
gingerBill ad685e1144 Compare floats by their bits in atomic compare-exchange; reject atomics on what is within a struct #packed 2026-10-07 21:50:16 +01:00
gingerBill 403738e5cd Merge pull request #7802 from odin-lang/bill/compiler-improvements-2026-10
Flow-based Escape Analysis of Stack Memory + Show where parapoly procedures and records were instantiated in errors within them
2026-10-07 21:19:06 +01:00
gingerBill d728de8a20 Add #+escape-analysis and #+no-escape-analysis file tags, and keep the syntactic check of unsafe returns where the escape analysis is disabled 2026-10-07 21:06:56 +01:00
gingerBill 6784db9f86 Add -no-escape-analysis, which cannot be used with -vet-nil-deref or -vet-uninitialized 2026-10-07 20:56:04 +01:00
gingerBill 476ff62d6d Add -vet-uninitialized, reporting reads of what is declared with --- before anything is stored in it 2026-10-07 20:35:53 +01:00