diff --git a/src/Sema.zig b/src/Sema.zig index b59159cbf28a09c3940ae6267840032f8dfbabe8..c3abfcd422e84002153603b71c3ad7e927fc73cb 100644 --- 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 index 7060dfaec4c6159c773029b7f0b213b7970df306..3e5b9a6e8f00431b864df14d9b6da9c976a1e893 100644 --- 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 index 885ca0aa1c9eb33540dae5e4a18c9cf1f7112222..4eec8b49a0ae6349208e84ee7fa6809b73520745 100644 --- 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, };