From 2d2a6ed1a46349355650bfdd68688738c67bbf9c Mon Sep 17 00:00:00 2001 From: Jacob G-W Date: Wed, 23 Jun 2021 14:32:21 -0400 Subject: stage2: implement @setRuntimeSafety --- src/Module.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index e168f6aac7..439256f320 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1151,6 +1151,9 @@ pub const Scope = struct { is_comptime: bool, + /// when null, it is determined by build mode, changed by @setRuntimeSafety + want_safety: ?bool = null, + /// This `Block` maps a block ZIR instruction to the corresponding /// AIR instruction for break instruction analysis. pub const Label = struct { @@ -1195,12 +1198,12 @@ pub const Scope = struct { .runtime_cond = parent.runtime_cond, .runtime_loop = parent.runtime_loop, .runtime_index = parent.runtime_index, + .want_safety = parent.want_safety, }; } pub fn wantSafety(block: *const Block) bool { - // TODO take into account scope's safety overrides - return switch (block.sema.mod.optimizeMode()) { + return block.want_safety orelse switch (block.sema.mod.optimizeMode()) { .Debug => true, .ReleaseSafe => true, .ReleaseFast => false, -- cgit v1.2.3