zig/test
mlugg 92c63126e8 compiler: tlv pointers are not comptime-known
Pointers to thread-local variables do not have their addresses known
until runtime, so it is nonsensical for them to be comptime-known. There
was logic in the compiler which was essentially attempting to treat them
as not being comptime-known despite the pointer being an interned value.
This was a bit of a mess, the check was frequent enough to actually show
up in compiler profiles, and it was very awkward for backends to deal
with, because they had to grapple with the fact that a "constant" they
were lowering might actually require runtime operations.

So, instead, do not consider these pointers to be comptime-known in
*any* way. Never intern such a pointer; instead, when the address of a
threadlocal is taken, emit an AIR instruction which computes the pointer
at runtime. This avoids lots of special handling for TLVs across
basically all codegen backends; of all somewhat-functional backends, the
only one which wasn't improved by this change was the LLVM backend,
because LLVM pretends this complexity around threadlocals doesn't exist.

This change simplifies Sema and codegen, avoids a potential source of
bugs, and potentially improves Sema performance very slightly by
avoiding a non-trivial check on a hot path.
2025-05-27 19:23:11 +01:00
..
behavior compiler: tlv pointers are not comptime-known 2025-05-27 19:23:11 +01:00
c_abi wasm-c-abi: llvm fix struct handling + reorganize 2025-05-01 18:10:36 -04:00
c_import translate-c: fix division and modulo of >8-bit stdint.h types in macros 2025-02-20 13:33:59 +02:00
cases compiler: tlv pointers are not comptime-known 2025-05-27 19:23:11 +01:00
incremental Zcu: fix nav_ty dependency on nav_val 2025-05-25 05:50:26 +01:00
link compiler: Allow configuring UBSan mode at the module level. 2025-04-26 22:54:34 +02:00
src Merge pull request #21882 from alexrp/compiler-fixes 2025-05-13 10:42:05 +02:00
standalone test-cli: port build options test to new build system API 2025-05-20 23:02:51 -04:00
assemble_and_link.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
behavior.zig test: add tests for @memmove 2025-04-26 13:34:17 +10:00
c_import.zig c_import: extract behavior tests that use @cImport 2024-02-20 18:44:43 +01:00
cases.zig remove test/cbe.zig 2024-03-28 15:24:01 +02:00
compare_output.zig std.heap: delete LoggingAllocator and friends 2025-02-06 14:23:23 -08:00
compile_errors.zig compiler: refactor Zcu.File and path representation 2025-05-18 17:37:02 +01:00
gen_h.zig all: zig fmt and rename "@XToY" to "@YFromX" 2023-06-19 12:34:42 -07:00
llvm_ir.zig test: Add some basic LLVM IR tests for atomics, volatile, and allowzero. 2025-05-12 17:07:50 +02:00
llvm_targets.zig test: Remove some nonsensical NetBSD targets from llvm_targets. 2025-05-17 04:41:26 +02:00
nvptx.zig Remove uses of deprecated callconv aliases 2025-03-05 03:01:43 +00:00
run_translated_c.zig remove hard tabs from source code 2024-07-31 16:57:42 -07:00
stack_traces.zig test: Disable error union switch with call operand (ReleaseSafe) on macos. 2025-04-04 06:08:10 +02:00
tests.zig Merge pull request #23815 from alichraghi/master 2025-05-25 12:36:53 +02:00
translate_c.zig compiler: Updates for LLVM/Clang 20 API changes. 2025-04-04 06:08:09 +02:00