zig reduce: fix compilation (#31930)

fixes #31926

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31930
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
This commit is contained in:
glowsquid
2026-04-22 02:00:41 +02:00
committed by Andrew Kelley
parent 3ea77badf9
commit 0b768cd9dd
4 changed files with 17 additions and 7 deletions
+3
View File
@@ -55,6 +55,9 @@ stage3-release/bin/zig build test docs \
stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=ReleaseSafe
stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug
# Ensure that reduce compiles
stage3-release/bin/zig reduce -h
# Ensure that stage3 and stage4 are byte-for-byte identical.
stage3-release/bin/zig build \
--maxrss ${ZSF_MAX_RSS:-0} \
+3
View File
@@ -77,6 +77,9 @@ stage3-release/bin/zig build test docs \
stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=ReleaseSafe
stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug
# Ensure that reduce compiles
stage3-release/bin/zig reduce -h
# Ensure that stage3 and stage4 are byte-for-byte identical.
stage3-release/bin/zig build \
--prefix stage4-release \
+4
View File
@@ -61,6 +61,10 @@ CheckLastExitCode
# stage3-release\bin\zig.exe build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug
# CheckLastExitCode
# Ensure that reduce compiles
stage3-release\bin\zig.exe build reduce -h
CheckLastExitCode
# Ensure that stage3 and stage4 are byte-for-byte identical.
Write-Output "Build and compare stage4..."
stage3-release\bin\zig.exe build `
+7 -7
View File
@@ -6,9 +6,9 @@ const BuiltinFn = std.zig.BuiltinFn;
ast: *const Ast,
transformations: *std.array_list.Managed(Transformation),
unreferenced_globals: std.StringArrayHashMapUnmanaged(Ast.Node.Index),
in_scope_names: std.StringArrayHashMapUnmanaged(u32),
replace_names: std.StringArrayHashMapUnmanaged(u32),
unreferenced_globals: std.array_hash_map.String(Ast.Node.Index),
in_scope_names: std.array_hash_map.String(u32),
replace_names: std.array_hash_map.String(u32),
gpa: std.mem.Allocator,
arena: std.mem.Allocator,
@@ -63,9 +63,9 @@ pub fn findTransformations(
.transformations = transformations,
.gpa = transformations.allocator,
.arena = arena,
.unreferenced_globals = .{},
.in_scope_names = .{},
.replace_names = .{},
.unreferenced_globals = .empty,
.in_scope_names = .empty,
.replace_names = .empty,
};
defer {
walk.unreferenced_globals.deinit(walk.gpa);
@@ -607,7 +607,7 @@ fn walkBlock(
{
try w.transformations.append(.{ .delete_var_decl = .{
.var_decl_node = stmt,
.references = .{},
.references = .empty,
} });
const name_tok = var_decl.ast.mut_token + 1;
const name_bytes = ast.tokenSlice(name_tok);