zig

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

commit 845b6a8efe5ac71c9df02373fe3716814cb7b92d (tree)
parent 95507faf1350f852174b43e6d6c2ea09339b8deb
Author: pentuppup <pentuppup@noreply.codeberg.org>
Date:   Thu, 30 Apr 2026 10:54:20 -0400

Zcu: remove optimizeMode(), fix usages

Diffstat:
Msrc/Sema.zig | 6+++---
Msrc/Zcu.zig | 7-------
Msrc/codegen/c.zig | 4++--
3 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/Sema.zig b/src/Sema.zig @@ -379,7 +379,7 @@ pub const Block = struct { /// pop the error trace upon block exit. error_return_trace_index: Air.Inst.Ref = .none, - /// when null, it is determined by build mode, changed by @setRuntimeSafety + /// when null, it is determined by the owner modules build mode, changed by @setRuntimeSafety want_safety: ?bool = null, /// What mode to generate float operations in, set by @setFloatMode @@ -532,7 +532,7 @@ pub const Block = struct { } fn wantSafeTypes(block: *const Block) bool { - return block.want_safety orelse switch (block.sema.pt.zcu.optimizeMode()) { + return block.want_safety orelse switch (block.ownerModule().optimize_mode) { .Debug => true, .ReleaseSafe => true, .ReleaseFast => false, @@ -542,7 +542,7 @@ pub const Block = struct { fn wantSafety(block: *const Block) bool { if (block.isComptime()) return false; // runtime safety checks are pointless in comptime blocks - return block.want_safety orelse switch (block.sema.pt.zcu.optimizeMode()) { + return block.want_safety orelse switch (block.ownerModule().optimize_mode) { .Debug => true, .ReleaseSafe => true, .ReleaseFast => false, diff --git a/src/Zcu.zig b/src/Zcu.zig @@ -3908,13 +3908,6 @@ pub fn getTarget(zcu: *const Zcu) *const Target { return &zcu.root_mod.resolved_target.result; } -/// Deprecated. There is no global optimization mode for a Zig Compilation -/// Unit. Instead, look up the optimization mode based on the Module that -/// contains the source code being analyzed. -pub fn optimizeMode(zcu: *const Zcu) std.builtin.OptimizeMode { - return zcu.root_mod.optimize_mode; -} - pub fn handleUpdateExports( zcu: *Zcu, export_indices: []const Export.Index, diff --git a/src/codegen/c.zig b/src/codegen/c.zig @@ -445,7 +445,7 @@ pub const Function = struct { } fn wantSafety(f: *Function) bool { - return switch (f.dg.pt.zcu.optimizeMode()) { + return switch (f.dg.mod.optimize_mode) { .Debug, .ReleaseSafe => true, .ReleaseFast, .ReleaseSmall => false, }; @@ -1301,7 +1301,7 @@ pub const DeclGen = struct { else => .initializer, }; - const safety_on = switch (zcu.optimizeMode()) { + const safety_on = switch (dg.mod.optimize_mode) { .Debug, .ReleaseSafe => true, .ReleaseFast, .ReleaseSmall => false, };