zig/lib
mlugg 9c3670fc93
compiler: implement analysis-local comptime-mutable memory
This commit changes how we represent comptime-mutable memory
(`comptime var`) in the compiler in order to implement the intended
behavior that references to such memory can only exist at comptime.

It does *not* clean up the representation of mutable values, improve the
representation of comptime-known pointers, or fix the many bugs in the
comptime pointer access code. These will be future enhancements.

Comptime memory lives for the duration of a single Sema, and is not
permitted to escape that one analysis, either by becoming runtime-known
or by becoming comptime-known to other analyses. These restrictions mean
that we can represent comptime allocations not via Decl, but with state
local to Sema - specifically, the new `Sema.comptime_allocs` field. All
comptime-mutable allocations, as well as any comptime-known const allocs
containing references to such memory, live in here. This allows for
relatively fast checking of whether a value references any
comptime-mtuable memory, since we need only traverse values up to
pointers: pointers to Decls can never reference comptime-mutable memory,
and pointers into `Sema.comptime_allocs` always do.

This change exposed some faulty pointer access logic in `Value.zig`.
I've fixed the important cases, but there are some TODOs I've put in
which are definitely possible to hit with sufficiently esoteric code. I
plan to resolve these by auditing all direct accesses to pointers (most
of them ought to use Sema to perform the pointer access!), but for now
this is sufficient for all realistic code and to get tests passing.

This change eliminates `Zcu.tmp_hack_arena`, instead using the Sema
arena for comptime memory mutations, which is possible since comptime
memory is now local to the current Sema.

This change should allow `Decl` to store only an `InternPool.Index`
rather than a full-blown `ty: Type, val: Value`. This commit does not
perform this refactor.
2024-03-25 14:49:41 +00:00
..
compiler reduce: fix compile errors 2024-03-24 17:29:39 +01:00
compiler_rt bsd: followup to std.posix extraction from std.os 2024-03-20 14:06:35 -07:00
docs Ast: fix comptime destructure 2024-03-17 15:23:16 -07:00
include update C language headers to LLVM 17 2023-09-19 09:37:31 -07:00
init Grammar fixes (#18320) 2023-12-20 13:17:15 +02:00
libc mingw-w64: update to latest master 2024-03-20 11:26:09 -07:00
libcxx update libcxx to latest LLVM release/17.x 2023-09-19 09:37:53 -07:00
libcxxabi libcxxabi: update to LLVM 17 2023-09-19 09:37:31 -07:00
libunwind libunwind: update to LLVM 17 2023-09-19 09:37:31 -07:00
std compiler: implement analysis-local comptime-mutable memory 2024-03-25 14:49:41 +00:00
tsan tsan: update rtl files to LLVM 17.0.6 2024-01-10 01:00:37 -07:00
c.zig std.builtin: make link mode fields lowercase 2024-03-11 07:09:10 -07:00
compiler_rt.zig move libssp into libcompiler_rt 2023-11-10 13:12:10 -07:00
zig.h cbe: fix non-msvc externs and exports 2024-01-03 02:52:25 -05:00