-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
pub const panic = @import("std").debug.no_panic;
fn ptrAddr(ptr: [*]const void, index: usize) *const void {
return &ptr[index];
}
fn ptrAccess(ptr: [*]const void, index: usize) void {
return ptr[index];
}
fn sliceAddr(slice: []const void, index: usize) *const void {
return &slice[index];
}
fn sliceAccess(slice: []const void, index: usize) void {
return slice[index];
}
fn unionInit(val: u8) union(enum) { val: u8 } {
return .{ .val = val };
}
fn unionAccess(val: union(enum(u1)) { only }) void {
return val.only;
}
fn errUnion(eu: error{Oops}!void) void {
if (eu) |_| {} else |_| {}
}
comptime {
_ = .{ &ptrAddr, &ptrAccess, &sliceAddr, &sliceAccess, &unionInit, &unionAccess, &errUnion };
}$ zig build-obj repro.zig --verbose-air
# Begin Function AIR: repro.ptrAddr:
# Total AIR+Liveness bytes: 283B
# AIR Instructions: 11 (99B)
# AIR Extra Data: 18 (72B)
# Liveness tomb_bits: 8B
# Liveness Extra Data: 0 (0B)
# Liveness special table: 0 (0B)
%0 = arg([*]const void, "ptr")
%1 = arg(usize, "index")
%2!= save_err_return_trace_index()
%3 = alloc(*[*]const void)
%4!= store_safe(%3, %0!)
%5 = bitcast(*const [*]const void, %3!)
%6!= dbg_stmt(2:16)
%7 = load([*]const void, %5!)
%8 = ptr_elem_ptr(*const void, %7!, %1!)
%9!= dbg_stmt(2:5)
%10!= ret_safe(%8!)
# End Function AIR: repro.ptrAddr
# Begin Function AIR: repro.ptrAccess:
# Total AIR+Liveness bytes: 223B
# AIR Instructions: 7 (63B)
# AIR Extra Data: 12 (48B)
# Liveness tomb_bits: 8B
# Liveness Extra Data: 0 (0B)
# Liveness special table: 0 (0B)
%0 = arg([*]const void, "ptr")
%1 = arg(usize, "index")
%2!= save_err_return_trace_index()
%3!= dbg_stmt(2:15)
%4 = ptr_elem_val(%0!, %1!)
%5!= dbg_stmt(2:5)
%6!= ret_safe(%4!)
# End Function AIR: repro.ptrAccess
# Begin Function AIR: repro.sliceAddr:
# Total AIR+Liveness bytes: 458B
# AIR Instructions: 18 (162B)
# AIR Extra Data: 33 (132B)
# Liveness tomb_bits: 16B
# Liveness Extra Data: 7 (28B)
# Liveness special table: 2 (16B)
%0 = arg([]const void, "slice")
%1 = arg(usize, "index")
%2!= save_err_return_trace_index()
%3 = alloc(*[]const void)
%4!= store_safe(%3, %0!)
%5 = bitcast(*const []const void, %3!)
%6!= dbg_stmt(2:18)
%7 = load([]const void, %5!)
%8 = slice_len(usize, %7)
%9 = cmp_lt(%1, %8)
%12!= block(void, {
%13!= cond_br(%9!, likely {
%8!
%14!= br(%12, @Air.Inst.Ref.void_value)
}, cold {
%7!
%10!= call(<fn (usize, usize) noreturn, (function 'outOfBounds')>, [%1!, %8!])
%11!= unreach()
})
} %8! %9!)
%15 = slice_elem_ptr(*const void, %7!, %1!)
%16!= dbg_stmt(2:5)
%17!= ret_safe(%15!)
# End Function AIR: repro.sliceAddr
# Begin Function AIR: repro.sliceAccess:
# Total AIR+Liveness bytes: 390B
# AIR Instructions: 14 (126B)
# AIR Extra Data: 27 (108B)
# Liveness tomb_bits: 8B
# Liveness Extra Data: 7 (28B)
# Liveness special table: 2 (16B)
%0 = arg([]const void, "slice")
%1 = arg(usize, "index")
%2!= save_err_return_trace_index()
%3!= dbg_stmt(2:17)
%4 = slice_len(usize, %0)
%5 = cmp_lt(%1, %4)
%8!= block(void, {
%9!= cond_br(%5!, likely {
%4!
%10!= br(%8, @Air.Inst.Ref.void_value)
}, cold {
%0!
%6!= call(<fn (usize, usize) noreturn, (function 'outOfBounds')>, [%1!, %4!])
%7!= unreach()
})
} %5! %4!)
%11 = slice_elem_val(%0!, %1!)
%12!= dbg_stmt(2:5)
%13!= ret_safe(%11!)
# End Function AIR: repro.sliceAccess
# Begin Function AIR: repro.unionInit:
# Total AIR+Liveness bytes: 241B
# AIR Instructions: 9 (81B)
# AIR Extra Data: 12 (48B)
# Liveness tomb_bits: 8B
# Liveness Extra Data: 0 (0B)
# Liveness special table: 0 (0B)
%0 = arg(u8, "val")
%1!= save_err_return_trace_index()
%2!= dbg_stmt(2:5)
%3 = ret_ptr(*repro.unionInit__union_197)
%4 = struct_field_ptr_index_0(*u8, %3)
%5!= store_safe(%4!, %0!)
%6!= set_union_tag(%3, <@typeInfo(repro.unionInit__union_197).@"union".tag_type.?, .val>)
%7!= dbg_stmt(2:5)
%8!= ret_load(%3!)
# End Function AIR: repro.unionInit
# Begin Function AIR: repro.unionAccess:
# Total AIR+Liveness bytes: 210B
# AIR Instructions: 6 (54B)
# AIR Extra Data: 11 (44B)
# Liveness tomb_bits: 8B
# Liveness Extra Data: 0 (0B)
# Liveness special table: 0 (0B)
%0 = arg(repro.unionAccess__union_203, "val")
%1!= save_err_return_trace_index()
%2!= dbg_stmt(2:15)
%3 = struct_field_val(%0!, 0)
%4!= dbg_stmt(2:5)
%5!= ret_safe(%3!)
# End Function AIR: repro.unionAccess
# Begin Function AIR: repro.errUnion:
# Total AIR+Liveness bytes: 328B
# AIR Instructions: 12 (108B)
# AIR Extra Data: 19 (76B)
# Liveness tomb_bits: 8B
# Liveness Extra Data: 4 (16B)
# Liveness special table: 2 (16B)
%0 = arg(error{Oops}!void, "eu")
%1!= save_err_return_trace_index()
%2!= dbg_stmt(2:9)
%3!= block(void, {
%4 = is_non_err(%0!)
%10!= cond_br(%4!, poi {
%5!= unwrap_errunion_payload(void, %0)
%6!= br(%3, @Air.Inst.Ref.void_value)
}, poi {
%7!= unwrap_errunion_err(error{Oops}, %0)
%8!= unwrap_errunion_err(error{Oops}, %0)
%9!= br(%3, @Air.Inst.Ref.void_value)
})
} %0!)
%11!= ret_safe(@Air.Inst.Ref.void_value)
# End Function AIR: repro.errUnion
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.