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 {
379379 /// pop the error trace upon block exit.
380380 error_return_trace_index: Air.Inst.Ref = .none,
381381
382 /// when null, it is determined by build mode, changed by @setRuntimeSafety
382 /// when null, it is determined by the owner modules build mode, changed by @setRuntimeSafety
383383 want_safety: ?bool = null,
384384
385385 /// What mode to generate float operations in, set by @setFloatMode
......@@ -532,7 +532,7 @@ pub const Block = struct {
532532 }
533533
534534 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) {
536536 .Debug => true,
537537 .ReleaseSafe => true,
538538 .ReleaseFast => false,
......@@ -542,7 +542,7 @@ pub const Block = struct {
542542
543543 fn wantSafety(block: *const Block) bool {
544544 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) {
546546 .Debug => true,
547547 .ReleaseSafe => true,
548548 .ReleaseFast => false,
src/Zcu.zig-7
......@@ -3908,13 +3908,6 @@ pub fn getTarget(zcu: *const Zcu) *const Target {
39083908 return &zcu.root_mod.resolved_target.result;
39093909}
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
39183911pub fn handleUpdateExports(
39193912 zcu: *Zcu,
39203913 export_indices: []const Export.Index,
src/codegen/c.zig+2-2
......@@ -445,7 +445,7 @@ pub const Function = struct {
445445 }
446446
447447 fn wantSafety(f: *Function) bool {
448 return switch (f.dg.pt.zcu.optimizeMode()) {
448 return switch (f.dg.mod.optimize_mode) {
449449 .Debug, .ReleaseSafe => true,
450450 .ReleaseFast, .ReleaseSmall => false,
451451 };
......@@ -1301,7 +1301,7 @@ pub const DeclGen = struct {
13011301 else => .initializer,
13021302 };
13031303
1304 const safety_on = switch (zcu.optimizeMode()) {
1304 const safety_on = switch (dg.mod.optimize_mode) {
13051305 .Debug, .ReleaseSafe => true,
13061306 .ReleaseFast, .ReleaseSmall => false,
13071307 };