Commit Graph
19858 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 8bf769b039 Add @(synchronizes=...) to Win32 SRW locks and critical sections 2026-10-08 23:09:05 +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 e0c1f9e325 Add @(synchronizes=...) to more primitives 2026-10-08 17:17:50 +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
gingerBill 9b0b76d0f7 Merge pull request #7826 from bbodi/fix/debug-info-printers
Fix/debug info printers
2026-10-08 16:10:53 +01:00
bbodi 3feb658b8f Pass -microarch:native to the split_globals tests
Every other test in tests/issues/run.sh passes -microarch:native
through $COMMON. These two lines spell their flags out, as the test is
a directory and $COMMON has -file, and left it off. On a CI virtual
machine whose CPU is older than the default x86-64-v2, `odin test`
refuses to run without it, which fails the NetBSD job at random.
2026-10-08 16:09:21 +02:00
BBandClaude Opus 5.5 3f5741c6b2 Take an any's basic types from Odin's type system
Apple's lldb includes Swift, and `SBTarget.GetBasicType` may answer
from Swift's type system, such as `Swift.Int64` for `long long`. A
value made from such a type is empty, so in about half of all lldb
sessions an `any` holding a basic type, or a pointer or an array of
one, showed only the name of its type. Ask the `any`'s own type for
basic types instead, as it comes from the type system of Odin's
debug info.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 16:07:18 +02:00
bbodi 1e8419d1d4 Fix core:simd/x86 AVX wrappers that did not build
Calling these failed to compile: `_mm256_round_pd` passed a u8 where
the intrinsic takes a u32, `_mm256_blend_pd` misspelt its parameter,
`_mm256_dp_ps` took its mask as an i8, `_mm_permute_ps/pd` used
SSE/SSE2 helpers without enabling them, and `_mm256_permute2f128_pd`
did not return its result.
2026-10-08 15:51:24 +02: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 a3c940fc01 Show an any holding a pointer or an array
An `any` holding a pointer, multi-pointer or fixed array printed raw,
as `{data = ..., id = ^int}`, since no debug type is named `^int` or
`[3]f32`. Build such types from their element, found by the rest of
the name, in both the gdb and lldb printers.
2026-10-08 15:31:57 +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 e22ae450af Show a union holding a pointer in the gdb printer
A non-nil `Maybe(^T)` or a #shared_nil union of pointers printed as
nothing, as gdb prints nothing for a pointer gdb.Value returned by a
printer's to_string. Return the pointer formatted as a string instead,
which is what the lldb summary already shows.
2026-10-08 15:30:28 +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
bbodi 1e1ea828a5 Fix intrinsic signatures in core:simd/x86
`_mm_cvtsd_ss` passed two `__m128d` to `llvm.x86.sse2.cvtsd2ss`,
which takes `(<4 x float>, <2 x double>)`, so LLVM failed with
"Intrinsic has incorrect argument type". `_mm_cvtss_sd` used
`llvm.x86.sse2.cvtss2sd`, which LLVM no longer has. Both wrappers
also took the wrong operand types; use Intel's (a: __m128, b: __m128d)
and (a: __m128d, b: __m128), and express `_mm_cvtss_sd` as a lane
conversion as clang does.

`_mm_prefetch` called `llvm.prefetch` without its pointer mangling and
`__rdtscp` declared `llvm.x86.rdtscp` as taking a pointer when it
returns `{i64, i32}`; both were rejected by LLVM too.
2026-10-08 15:12:18 +02:00
bbodi 26912ceb95 Replace removed LLVM intrinsics in core:simd/x86
LLVM has dropped many x86 intrinsics in favour of generic IR, and
auto-upgrades them only when reading bitcode. Odin declares them
directly, so the calls became undefined external symbols and failed
to link, e.g. `undefined reference to llvm.x86.sse41.pmaxsb`.

Express the affected wrappers the way clang's headers now do: scalar
lane ops, simd.min/max/abs/sqrt, shuffles for the immediate blends,
masked or narrowed multiplies, conversions and an unaligned store.
`_addcarryx_*` now use `llvm.x86.addcarry.*`, as clang does.

`_mm_sqrt_ss` took an unused second argument; it now takes one, as
in Intel's definition. It could not have been used before.
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
gingerBill 311394cfbc Clean up odin_debugger.py 2026-10-08 13:32:11 +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 756e0daac0 Show #soa arrays, set-like maps, allocators and any values in the gdb and lldb printers 2026-10-08 13:20:11 +01: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 5caf8b7408 Add gdb and lldb pretty printers for map, union, strings, slices, and dynamic arrays 2026-10-08 11:43:12 +01:00
gingerBill ba52d1485f Merge pull request #7821 from odin-lang/bill/7820
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:16:22 +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 fa88124d6c Merge pull request #7819 from odin-lang/bill/atomics
Improved Atomic Analysis: Fences, Weak Compare-Exchange, Futex Wakes, and Volatile Memory Access
2026-10-08 10:56:38 +01:00
Jeroen van Rijn a961bb5ddb Merge pull request #7818 from bbodi/fix/sha3-init-round-start
Reset keccak_round_start in _sha3.init
2026-10-08 02:51:19 -07: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
bbodi f7f3e63191 Reset keccak_round_start in _sha3.init
init left the round start untouched. A context that skipped zeroing
with `= ---`, or one reused after TurboSHAKE, kept a stale value, so
SHA-3 and SHAKE ran too few rounds and returned wrong hashes silently.
2026-10-08 11:02:47 +02:00
Jeroen van Rijn 4d09219ff4 Merge pull request #7616 from wardjm/fix/parse_int_overflow
Fixed strconv overflow noted in issue#7608.
2026-10-08 01:57:40 -07: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