authorgravatar for pentuppup@noreply.codeberg.orgpentuppup <pentuppup@noreply.codeberg.org> 2026-04-30 10:54:20-04:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-01 10:39:43+02:00
log845b6a8efe5ac71c9df02373fe3716814cb7b92d
treea74b61bdc6128b5d8f6a440bfc52318736d3b5c8
parent95507faf1350f852174b43e6d6c2ea09339b8deb

Zcu: remove optimizeMode(), fix usages


3 files changed, 5 insertions(+), 12 deletions(-)

src/Sema.zig+3-3
...@@ -379,7 +379,7 @@ pub const Block = struct {...@@ -379,7 +379,7 @@ pub const Block = struct {
379 /// pop the error trace upon block exit.379 /// pop the error trace upon block exit.
380 error_return_trace_index: Air.Inst.Ref = .none,380 error_return_trace_index: Air.Inst.Ref = .none,
381381
382 /// when null, it is determined by build mode, changed by @setRuntimeSafety382 /// when null, it is determined by the owner modules build mode, changed by @setRuntimeSafety
383 want_safety: ?bool = null,383 want_safety: ?bool = null,
384384
385 /// What mode to generate float operations in, set by @setFloatMode385 /// What mode to generate float operations in, set by @setFloatMode
...@@ -532,7 +532,7 @@ pub const Block = struct {...@@ -532,7 +532,7 @@ pub const Block = struct {
532 }532 }
533533
534 fn wantSafeTypes(block: *const Block) bool {534 fn wantSafeTypes(block: *const Block) bool {
535 return block.want_safety orelse switch (block.sema.pt.zcu.optimizeMode()) {535 return block.want_safety orelse switch (block.ownerModule().optimize_mode) {
536 .Debug => true,536 .Debug => true,
537 .ReleaseSafe => true,537 .ReleaseSafe => true,
538 .ReleaseFast => false,538 .ReleaseFast => false,
...@@ -542,7 +542,7 @@ pub const Block = struct {...@@ -542,7 +542,7 @@ pub const Block = struct {
542542
543 fn wantSafety(block: *const Block) bool {543 fn wantSafety(block: *const Block) bool {
544 if (block.isComptime()) return false; // runtime safety checks are pointless in comptime blocks544 if (block.isComptime()) return false; // runtime safety checks are pointless in comptime blocks
545 return block.want_safety orelse switch (block.sema.pt.zcu.optimizeMode()) {545 return block.want_safety orelse switch (block.ownerModule().optimize_mode) {
546 .Debug => true,546 .Debug => true,
547 .ReleaseSafe => true,547 .ReleaseSafe => true,
548 .ReleaseFast => false,548 .ReleaseFast => false,
src/Zcu.zig-7
...@@ -3908,13 +3908,6 @@ pub fn getTarget(zcu: *const Zcu) *const Target {...@@ -3908,13 +3908,6 @@ pub fn getTarget(zcu: *const Zcu) *const Target {
3908 return &zcu.root_mod.resolved_target.result;3908 return &zcu.root_mod.resolved_target.result;
3909}3909}
39103910
3911/// Deprecated. There is no global optimization mode for a Zig Compilation
3912/// Unit. Instead, look up the optimization mode based on the Module that
3913/// contains the source code being analyzed.
3914pub fn optimizeMode(zcu: *const Zcu) std.builtin.OptimizeMode {
3915 return zcu.root_mod.optimize_mode;
3916}
3917
3918pub fn handleUpdateExports(3911pub fn handleUpdateExports(
3919 zcu: *Zcu,3912 zcu: *Zcu,
3920 export_indices: []const Export.Index,3913 export_indices: []const Export.Index,
src/codegen/c.zig+2-2
...@@ -445,7 +445,7 @@ pub const Function = struct {...@@ -445,7 +445,7 @@ pub const Function = struct {
445 }445 }
446446
447 fn wantSafety(f: *Function) bool {447 fn wantSafety(f: *Function) bool {
448 return switch (f.dg.pt.zcu.optimizeMode()) {448 return switch (f.dg.mod.optimize_mode) {
449 .Debug, .ReleaseSafe => true,449 .Debug, .ReleaseSafe => true,
450 .ReleaseFast, .ReleaseSmall => false,450 .ReleaseFast, .ReleaseSmall => false,
451 };451 };
...@@ -1301,7 +1301,7 @@ pub const DeclGen = struct {...@@ -1301,7 +1301,7 @@ pub const DeclGen = struct {
1301 else => .initializer,1301 else => .initializer,
1302 };1302 };
13031303
1304 const safety_on = switch (zcu.optimizeMode()) {1304 const safety_on = switch (dg.mod.optimize_mode) {
1305 .Debug, .ReleaseSafe => true,1305 .Debug, .ReleaseSafe => true,
1306 .ReleaseFast, .ReleaseSmall => false,1306 .ReleaseFast, .ReleaseSmall => false,
1307 };1307 };