zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit bd709678f66635ec63f151fba23dc38c886b0deb (tree)
parent 164b4ad79c359cbeba3b9bab2317083dd1a2de2e
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date:   Tue, 17 Feb 2026 07:13:25 +0000

astgen: handle @frameAddress in rlBuiltinCall, enable debug.zig

rlBuiltinCall was always returning false (not consuming result location).
The Zig reference marks @frameAddress as consuming the RL (workaround for
llvm/llvm-project#68409), which affects declaration codegen path (pointer
vs value based). Match the upstream behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Diffstat:
Mstage0/astgen.c | 26+++++++++++++++++++++++---
Mstage0/stages_test.zig | 2+-
2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/stage0/astgen.c b/stage0/astgen.c @@ -18036,11 +18036,31 @@ static bool rlBlockExpr(AstGenCtx* ag, RlBlock* parent_block, RlResultInfo ri, } // builtinCall (AstRlAnnotate.zig:816-1100). -// Simplified: no builtin currently consumes its result location, -// so we just recurse into all args with RL_RI_NONE. static bool rlBuiltinCall(AstGenCtx* ag, RlBlock* block, uint32_t node, const uint32_t* args, uint32_t nargs) { - (void)node; + const Ast* tree = ag->tree; + uint32_t builtin_token = tree->nodes.main_tokens[node]; + uint32_t tok_start = tree->tokens.starts[builtin_token]; + const char* source = tree->source; + uint32_t name_start = tok_start + 1; // skip '@' + uint32_t name_end = name_start; + while (name_end < tree->source_len + && ((source[name_end] >= 'a' && source[name_end] <= 'z') + || (source[name_end] >= 'A' && source[name_end] <= 'Z') + || (source[name_end] >= '0' && source[name_end] <= '9') + || source[name_end] == '_')) { + name_end++; + } + uint32_t name_len = name_end - name_start; + + // TODO: this is a workaround for llvm/llvm-project#68409 + // Zig tracking issue: #16876 + // @frameAddress consumes its result location + // (AstRlAnnotate.zig:887-889). + if (name_len == 12 + && memcmp(source + name_start, "frameAddress", 12) == 0) + return true; + for (uint32_t i = 0; i < nargs; i++) (void)rlExpr(ag, args[i], block, RL_RI_NONE); return false; diff --git a/stage0/stages_test.zig b/stage0/stages_test.zig @@ -590,7 +590,7 @@ const corpus_files = .{ "../lib/std/debug/Pdb.zig", "../lib/std/debug/SelfInfo.zig", "../lib/std/debug/simple_panic.zig", - //"../lib/std/debug.zig", + "../lib/std/debug.zig", "../lib/std/DoublyLinkedList.zig", "../lib/std/dwarf/ATE.zig", "../lib/std/dwarf/AT.zig",