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_end,
.c_va_start,
.add_safe,
.sub_safe,
.mul_safe,
=> true,
.add,
.add_safe,
.add_optimized,
.add_wrap,
.add_sat,
.sub,
.sub_safe,
.sub_optimized,
.sub_wrap,
.sub_sat,
.mul,
.mul_safe,
.mul_optimized,
.mul_wrap,
.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