Liveness: do not elide safety-checked instructions

Resolves: #19012
This commit is contained in:
mlugg 2024-02-20 03:53:42 +00:00 committed by Matthew Lugg
parent 97290e0bfc
commit 65a87ff299
2 changed files with 24 additions and 3 deletions

View File

@ -1646,20 +1646,20 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
.c_va_copy, .c_va_copy,
.c_va_end, .c_va_end,
.c_va_start, .c_va_start,
.add_safe,
.sub_safe,
.mul_safe,
=> true, => true,
.add, .add,
.add_safe,
.add_optimized, .add_optimized,
.add_wrap, .add_wrap,
.add_sat, .add_sat,
.sub, .sub,
.sub_safe,
.sub_optimized, .sub_optimized,
.sub_wrap, .sub_wrap,
.sub_sat, .sub_sat,
.mul, .mul,
.mul_safe,
.mul_optimized, .mul_optimized,
.mul_wrap, .mul_wrap,
.mul_sat, .mul_sat,

View File

@ -0,0 +1,21 @@
const std = @import("std");
pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
_ = stack_trace;
if (std.mem.eql(u8, message, "integer overflow")) {
std.process.exit(0);
}
std.process.exit(1);
}
pub fn main() !void {
var x: usize = undefined;
x = 0;
// We ignore this result but it should still trigger a safety panic!
_ = x - 1;
return error.TestFailed;
}
// run
// backend=llvm
// target=native