authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-04-06 05:26:20+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-04-07 01:29:20+01:00
log1059b57898ec929e9d6ebd8c35660acffe0bac99
tree128f9f9e8d9563bee84705f518b7c888bdeada3f
parent13aa7871b274fd22c7fdf277174a43d09788bd27
signaturelock-open Commit is signed but in an unrecognized format.

Liveness: defer deaths of externally-scoped instructions in loop bodies


11 files changed, 713 insertions(+), 66 deletions(-)

src/Liveness.zig+619-1
......@@ -25,6 +25,7 @@ tomb_bits: []usize,
2525/// array. The meaning of the data depends on the AIR tag.
2626/// * `cond_br` - points to a `CondBr` in `extra` at this index.
2727/// * `switch_br` - points to a `SwitchBr` in `extra` at this index.
28/// * `loop` - points to a `Loop` in `extra` at this index.
2829/// * `asm`, `call`, `aggregate_init` - the value is a set of bits which are the extra tomb
2930/// bits of operands.
3031/// The main tomb bits are still used and the extra ones are starting with the lsb of the
......@@ -51,6 +52,11 @@ pub const SwitchBr = struct {
5152 else_death_count: u32,
5253};
5354
55/// Trailing is the set of instructions whose lifetimes end at the end of the loop body.
56pub const Loop = struct {
57 death_count: u32,
58};
59
5460pub fn analyze(gpa: Allocator, air: Air) Allocator.Error!Liveness {
5561 const tracy = trace(@src());
5662 defer tracy.end();
......@@ -76,6 +82,11 @@ pub fn analyze(gpa: Allocator, air: Air) Allocator.Error!Liveness {
7682 const main_body = air.getMainBody();
7783 try a.table.ensureTotalCapacity(gpa, @intCast(u32, main_body.len));
7884 try analyzeWithContext(&a, null, main_body);
85 {
86 var to_remove: std.AutoHashMapUnmanaged(Air.Inst.Index, void) = .{};
87 defer to_remove.deinit(gpa);
88 try removeDeaths(&a, &to_remove, main_body);
89 }
7990 return Liveness{
8091 .tomb_bits = a.tomb_bits,
8192 .special = a.special,
......@@ -650,6 +661,18 @@ pub fn getSwitchBr(l: Liveness, gpa: Allocator, inst: Air.Inst.Index, cases_len:
650661 };
651662}
652663
664pub const LoopSlice = struct {
665 deaths: []const Air.Inst.Index,
666};
667
668pub fn getLoop(l: Liveness, inst: Air.Inst.Index) LoopSlice {
669 const index: usize = l.special.get(inst) orelse return .{
670 .deaths = &.{},
671 };
672 const death_count = l.extra[index];
673 return .{ .deaths = l.extra[index + 1 ..][0..death_count] };
674}
675
653676pub fn deinit(l: *Liveness, gpa: Allocator) void {
654677 gpa.free(l.tomb_bits);
655678 gpa.free(l.extra);
......@@ -1138,7 +1161,39 @@ fn analyzeInst(
11381161 .loop => {
11391162 const extra = a.air.extraData(Air.Block, inst_datas[inst].ty_pl.payload);
11401163 const body = a.air.extra[extra.end..][0..extra.data.body_len];
1141 try analyzeWithContext(a, new_set, body);
1164
1165 var body_table: std.AutoHashMapUnmanaged(Air.Inst.Index, void) = .{};
1166 defer body_table.deinit(gpa);
1167
1168 // Instructions outside the loop body cannot die within the loop, since further loop
1169 // iterations may occur. Track deaths from the loop body - we'll remove all of these
1170 // retroactively, and add them to our extra data.
1171
1172 try analyzeWithContext(a, &body_table, body);
1173
1174 if (new_set) |ns| {
1175 try ns.ensureUnusedCapacity(gpa, body_table.count());
1176 var it = body_table.keyIterator();
1177 while (it.next()) |key| {
1178 _ = ns.putAssumeCapacity(key.*, {});
1179 }
1180 }
1181
1182 try a.extra.ensureUnusedCapacity(gpa, std.meta.fields(Loop).len + body_table.count());
1183 const extra_index = a.addExtraAssumeCapacity(Loop{
1184 .death_count = body_table.count(),
1185 });
1186 {
1187 var it = body_table.keyIterator();
1188 while (it.next()) |key| {
1189 a.extra.appendAssumeCapacity(key.*);
1190 }
1191 }
1192 try a.special.put(gpa, inst, extra_index);
1193
1194 // We'll remove invalid deaths in a separate pass after main liveness analysis. See
1195 // removeDeaths for more details.
1196
11421197 return; // Loop has no operands and it is always unreferenced.
11431198 },
11441199 .@"try" => {
......@@ -1412,3 +1467,566 @@ const ExtraTombs = struct {
14121467 et.big_tomb_bits_extra.deinit(et.analysis.gpa);
14131468 }
14141469};
1470
1471/// Remove any deaths invalidated by the deaths from an enclosing `loop`. Reshuffling deaths stored
1472/// in `extra` causes it to become non-dense, but that's fine - we won't remove too much data.
1473/// Making it dense would be a lot more work - it'd require recomputing every index in `special`.
1474fn removeDeaths(
1475 a: *Analysis,
1476 to_remove: *std.AutoHashMapUnmanaged(Air.Inst.Index, void),
1477 body: []const Air.Inst.Index,
1478) error{OutOfMemory}!void {
1479 for (body) |inst| {
1480 try removeInstDeaths(a, to_remove, inst);
1481 }
1482}
1483
1484fn removeInstDeaths(
1485 a: *Analysis,
1486 to_remove: *std.AutoHashMapUnmanaged(Air.Inst.Index, void),
1487 inst: Air.Inst.Index,
1488) !void {
1489 const inst_tags = a.air.instructions.items(.tag);
1490 const inst_datas = a.air.instructions.items(.data);
1491
1492 switch (inst_tags[inst]) {
1493 .add,
1494 .add_optimized,
1495 .addwrap,
1496 .addwrap_optimized,
1497 .add_sat,
1498 .sub,
1499 .sub_optimized,
1500 .subwrap,
1501 .subwrap_optimized,
1502 .sub_sat,
1503 .mul,
1504 .mul_optimized,
1505 .mulwrap,
1506 .mulwrap_optimized,
1507 .mul_sat,
1508 .div_float,
1509 .div_float_optimized,
1510 .div_trunc,
1511 .div_trunc_optimized,
1512 .div_floor,
1513 .div_floor_optimized,
1514 .div_exact,
1515 .div_exact_optimized,
1516 .rem,
1517 .rem_optimized,
1518 .mod,
1519 .mod_optimized,
1520 .bit_and,
1521 .bit_or,
1522 .xor,
1523 .cmp_lt,
1524 .cmp_lt_optimized,
1525 .cmp_lte,
1526 .cmp_lte_optimized,
1527 .cmp_eq,
1528 .cmp_eq_optimized,
1529 .cmp_gte,
1530 .cmp_gte_optimized,
1531 .cmp_gt,
1532 .cmp_gt_optimized,
1533 .cmp_neq,
1534 .cmp_neq_optimized,
1535 .bool_and,
1536 .bool_or,
1537 .store,
1538 .array_elem_val,
1539 .slice_elem_val,
1540 .ptr_elem_val,
1541 .shl,
1542 .shl_exact,
1543 .shl_sat,
1544 .shr,
1545 .shr_exact,
1546 .atomic_store_unordered,
1547 .atomic_store_monotonic,
1548 .atomic_store_release,
1549 .atomic_store_seq_cst,
1550 .set_union_tag,
1551 .min,
1552 .max,
1553 => {
1554 const o = inst_datas[inst].bin_op;
1555 removeOperandDeaths(a, to_remove, inst, .{ o.lhs, o.rhs, .none });
1556 },
1557
1558 .vector_store_elem => {
1559 const o = inst_datas[inst].vector_store_elem;
1560 const extra = a.air.extraData(Air.Bin, o.payload).data;
1561 removeOperandDeaths(a, to_remove, inst, .{ o.vector_ptr, extra.lhs, extra.rhs });
1562 },
1563
1564 .arg,
1565 .alloc,
1566 .ret_ptr,
1567 .constant,
1568 .const_ty,
1569 .trap,
1570 .breakpoint,
1571 .dbg_stmt,
1572 .dbg_inline_begin,
1573 .dbg_inline_end,
1574 .dbg_block_begin,
1575 .dbg_block_end,
1576 .unreach,
1577 .fence,
1578 .ret_addr,
1579 .frame_addr,
1580 .wasm_memory_size,
1581 .err_return_trace,
1582 .save_err_return_trace_index,
1583 .c_va_start,
1584 .work_item_id,
1585 .work_group_size,
1586 .work_group_id,
1587 => {},
1588
1589 .not,
1590 .bitcast,
1591 .load,
1592 .fpext,
1593 .fptrunc,
1594 .intcast,
1595 .trunc,
1596 .optional_payload,
1597 .optional_payload_ptr,
1598 .optional_payload_ptr_set,
1599 .errunion_payload_ptr_set,
1600 .wrap_optional,
1601 .unwrap_errunion_payload,
1602 .unwrap_errunion_err,
1603 .unwrap_errunion_payload_ptr,
1604 .unwrap_errunion_err_ptr,
1605 .wrap_errunion_payload,
1606 .wrap_errunion_err,
1607 .slice_ptr,
1608 .slice_len,
1609 .ptr_slice_len_ptr,
1610 .ptr_slice_ptr_ptr,
1611 .struct_field_ptr_index_0,
1612 .struct_field_ptr_index_1,
1613 .struct_field_ptr_index_2,
1614 .struct_field_ptr_index_3,
1615 .array_to_slice,
1616 .float_to_int,
1617 .float_to_int_optimized,
1618 .int_to_float,
1619 .get_union_tag,
1620 .clz,
1621 .ctz,
1622 .popcount,
1623 .byte_swap,
1624 .bit_reverse,
1625 .splat,
1626 .error_set_has_value,
1627 .addrspace_cast,
1628 .c_va_arg,
1629 .c_va_copy,
1630 => {
1631 const o = inst_datas[inst].ty_op;
1632 removeOperandDeaths(a, to_remove, inst, .{ o.operand, .none, .none });
1633 },
1634
1635 .is_null,
1636 .is_non_null,
1637 .is_null_ptr,
1638 .is_non_null_ptr,
1639 .is_err,
1640 .is_non_err,
1641 .is_err_ptr,
1642 .is_non_err_ptr,
1643 .ptrtoint,
1644 .bool_to_int,
1645 .ret,
1646 .ret_load,
1647 .is_named_enum_value,
1648 .tag_name,
1649 .error_name,
1650 .sqrt,
1651 .sin,
1652 .cos,
1653 .tan,
1654 .exp,
1655 .exp2,
1656 .log,
1657 .log2,
1658 .log10,
1659 .fabs,
1660 .floor,
1661 .ceil,
1662 .round,
1663 .trunc_float,
1664 .neg,
1665 .neg_optimized,
1666 .cmp_lt_errors_len,
1667 .set_err_return_trace,
1668 .c_va_end,
1669 => {
1670 const operand = inst_datas[inst].un_op;
1671 removeOperandDeaths(a, to_remove, inst, .{ operand, .none, .none });
1672 },
1673
1674 .add_with_overflow,
1675 .sub_with_overflow,
1676 .mul_with_overflow,
1677 .shl_with_overflow,
1678 .ptr_add,
1679 .ptr_sub,
1680 .ptr_elem_ptr,
1681 .slice_elem_ptr,
1682 .slice,
1683 => {
1684 const ty_pl = inst_datas[inst].ty_pl;
1685 const extra = a.air.extraData(Air.Bin, ty_pl.payload).data;
1686 removeOperandDeaths(a, to_remove, inst, .{ extra.lhs, extra.rhs, .none });
1687 },
1688
1689 .dbg_var_ptr,
1690 .dbg_var_val,
1691 => {
1692 const operand = inst_datas[inst].pl_op.operand;
1693 removeOperandDeaths(a, to_remove, inst, .{ operand, .none, .none });
1694 },
1695
1696 .prefetch => {
1697 const prefetch = inst_datas[inst].prefetch;
1698 removeOperandDeaths(a, to_remove, inst, .{ prefetch.ptr, .none, .none });
1699 },
1700
1701 .call, .call_always_tail, .call_never_tail, .call_never_inline => {
1702 const inst_data = inst_datas[inst].pl_op;
1703 const callee = inst_data.operand;
1704 const extra = a.air.extraData(Air.Call, inst_data.payload);
1705 const args = @ptrCast([]const Air.Inst.Ref, a.air.extra[extra.end..][0..extra.data.args_len]);
1706
1707 var death_remover = BigTombDeathRemover.init(a, to_remove, inst);
1708 death_remover.feed(callee);
1709 for (args) |operand| {
1710 death_remover.feed(operand);
1711 }
1712 death_remover.finish();
1713 },
1714 .select => {
1715 const pl_op = inst_datas[inst].pl_op;
1716 const extra = a.air.extraData(Air.Bin, pl_op.payload).data;
1717 removeOperandDeaths(a, to_remove, inst, .{ pl_op.operand, extra.lhs, extra.rhs });
1718 },
1719 .shuffle => {
1720 const extra = a.air.extraData(Air.Shuffle, inst_datas[inst].ty_pl.payload).data;
1721 removeOperandDeaths(a, to_remove, inst, .{ extra.a, extra.b, .none });
1722 },
1723 .reduce, .reduce_optimized => {
1724 const reduce = inst_datas[inst].reduce;
1725 removeOperandDeaths(a, to_remove, inst, .{ reduce.operand, .none, .none });
1726 },
1727 .cmp_vector, .cmp_vector_optimized => {
1728 const extra = a.air.extraData(Air.VectorCmp, inst_datas[inst].ty_pl.payload).data;
1729 removeOperandDeaths(a, to_remove, inst, .{ extra.lhs, extra.rhs, .none });
1730 },
1731 .aggregate_init => {
1732 const ty_pl = inst_datas[inst].ty_pl;
1733 const aggregate_ty = a.air.getRefType(ty_pl.ty);
1734 const len = @intCast(usize, aggregate_ty.arrayLen());
1735 const elements = @ptrCast([]const Air.Inst.Ref, a.air.extra[ty_pl.payload..][0..len]);
1736
1737 var death_remover = BigTombDeathRemover.init(a, to_remove, inst);
1738 for (elements) |elem| {
1739 death_remover.feed(elem);
1740 }
1741 death_remover.finish();
1742 },
1743 .union_init => {
1744 const extra = a.air.extraData(Air.UnionInit, inst_datas[inst].ty_pl.payload).data;
1745 removeOperandDeaths(a, to_remove, inst, .{ extra.init, .none, .none });
1746 },
1747 .struct_field_ptr, .struct_field_val => {
1748 const extra = a.air.extraData(Air.StructField, inst_datas[inst].ty_pl.payload).data;
1749 removeOperandDeaths(a, to_remove, inst, .{ extra.struct_operand, .none, .none });
1750 },
1751 .field_parent_ptr => {
1752 const extra = a.air.extraData(Air.FieldParentPtr, inst_datas[inst].ty_pl.payload).data;
1753 removeOperandDeaths(a, to_remove, inst, .{ extra.field_ptr, .none, .none });
1754 },
1755 .cmpxchg_strong, .cmpxchg_weak => {
1756 const extra = a.air.extraData(Air.Cmpxchg, inst_datas[inst].ty_pl.payload).data;
1757 removeOperandDeaths(a, to_remove, inst, .{ extra.ptr, extra.expected_value, extra.new_value });
1758 },
1759 .mul_add => {
1760 const pl_op = inst_datas[inst].pl_op;
1761 const extra = a.air.extraData(Air.Bin, pl_op.payload).data;
1762 removeOperandDeaths(a, to_remove, inst, .{ extra.lhs, extra.rhs, pl_op.operand });
1763 },
1764 .atomic_load => {
1765 const ptr = inst_datas[inst].atomic_load.ptr;
1766 removeOperandDeaths(a, to_remove, inst, .{ ptr, .none, .none });
1767 },
1768 .atomic_rmw => {
1769 const pl_op = inst_datas[inst].pl_op;
1770 const extra = a.air.extraData(Air.AtomicRmw, pl_op.payload).data;
1771 removeOperandDeaths(a, to_remove, inst, .{ pl_op.operand, extra.operand, .none });
1772 },
1773 .memset,
1774 .memcpy,
1775 => {
1776 const pl_op = inst_datas[inst].pl_op;
1777 const extra = a.air.extraData(Air.Bin, pl_op.payload).data;
1778 removeOperandDeaths(a, to_remove, inst, .{ pl_op.operand, extra.lhs, extra.rhs });
1779 },
1780
1781 .br => {
1782 const br = inst_datas[inst].br;
1783 removeOperandDeaths(a, to_remove, inst, .{ br.operand, .none, .none });
1784 },
1785 .assembly => {
1786 const extra = a.air.extraData(Air.Asm, inst_datas[inst].ty_pl.payload);
1787 var extra_i: usize = extra.end;
1788 const outputs = @ptrCast([]const Air.Inst.Ref, a.air.extra[extra_i..][0..extra.data.outputs_len]);
1789 extra_i += outputs.len;
1790 const inputs = @ptrCast([]const Air.Inst.Ref, a.air.extra[extra_i..][0..extra.data.inputs_len]);
1791 extra_i += inputs.len;
1792
1793 var death_remover = BigTombDeathRemover.init(a, to_remove, inst);
1794 for (outputs) |output| {
1795 if (output != .none) {
1796 death_remover.feed(output);
1797 }
1798 }
1799 for (inputs) |input| {
1800 death_remover.feed(input);
1801 }
1802 death_remover.finish();
1803 },
1804 .block => {
1805 const extra = a.air.extraData(Air.Block, inst_datas[inst].ty_pl.payload);
1806 const body = a.air.extra[extra.end..][0..extra.data.body_len];
1807 try removeDeaths(a, to_remove, body);
1808 },
1809 .loop => {
1810 const extra = a.air.extraData(Air.Block, inst_datas[inst].ty_pl.payload);
1811 const body = a.air.extra[extra.end..][0..extra.data.body_len];
1812
1813 const liveness_extra_idx = a.special.get(inst) orelse {
1814 try removeDeaths(a, to_remove, body);
1815 return;
1816 };
1817
1818 const death_count = a.extra.items[liveness_extra_idx];
1819 var deaths = a.extra.items[liveness_extra_idx + 1 ..][0..death_count];
1820
1821 // Remove any deaths in `to_remove` from this loop's deaths
1822 deaths.len = removeExtraDeaths(to_remove, deaths);
1823 a.extra.items[liveness_extra_idx] = @intCast(u32, deaths.len);
1824
1825 // Temporarily add any deaths of ours to `to_remove`
1826 try to_remove.ensureUnusedCapacity(a.gpa, @intCast(u32, deaths.len));
1827 for (deaths) |d| {
1828 to_remove.putAssumeCapacity(d, {});
1829 }
1830 try removeDeaths(a, to_remove, body);
1831 for (deaths) |d| {
1832 _ = to_remove.remove(d);
1833 }
1834 },
1835 .@"try" => {
1836 const pl_op = inst_datas[inst].pl_op;
1837 const extra = a.air.extraData(Air.Try, pl_op.payload);
1838 const body = a.air.extra[extra.end..][0..extra.data.body_len];
1839 try removeDeaths(a, to_remove, body);
1840 removeOperandDeaths(a, to_remove, inst, .{ pl_op.operand, .none, .none });
1841 },
1842 .try_ptr => {
1843 const extra = a.air.extraData(Air.TryPtr, inst_datas[inst].ty_pl.payload);
1844 const body = a.air.extra[extra.end..][0..extra.data.body_len];
1845 try removeDeaths(a, to_remove, body);
1846 removeOperandDeaths(a, to_remove, inst, .{ extra.data.ptr, .none, .none });
1847 },
1848 .cond_br => {
1849 const inst_data = inst_datas[inst].pl_op;
1850 const condition = inst_data.operand;
1851 const extra = a.air.extraData(Air.CondBr, inst_data.payload);
1852 const then_body = a.air.extra[extra.end..][0..extra.data.then_body_len];
1853 const else_body = a.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
1854
1855 if (a.special.get(inst)) |liveness_extra_idx| {
1856 const then_death_count = a.extra.items[liveness_extra_idx + 0];
1857 const else_death_count = a.extra.items[liveness_extra_idx + 1];
1858 var then_deaths = a.extra.items[liveness_extra_idx + 2 ..][0..then_death_count];
1859 var else_deaths = a.extra.items[liveness_extra_idx + 2 + then_death_count ..][0..else_death_count];
1860
1861 const new_then_death_count = removeExtraDeaths(to_remove, then_deaths);
1862 const new_else_death_count = removeExtraDeaths(to_remove, else_deaths);
1863
1864 a.extra.items[liveness_extra_idx + 0] = new_then_death_count;
1865 a.extra.items[liveness_extra_idx + 1] = new_else_death_count;
1866
1867 if (new_then_death_count < then_death_count) {
1868 // `else` deaths need to be moved earlier in `extra`
1869 const src = a.extra.items[liveness_extra_idx + 2 + then_death_count ..];
1870 const dest = a.extra.items[liveness_extra_idx + 2 + new_then_death_count ..];
1871 std.mem.copy(u32, dest, src[0..new_else_death_count]);
1872 }
1873 }
1874
1875 try removeDeaths(a, to_remove, then_body);
1876 try removeDeaths(a, to_remove, else_body);
1877
1878 removeOperandDeaths(a, to_remove, inst, .{ condition, .none, .none });
1879 },
1880 .switch_br => {
1881 const pl_op = inst_datas[inst].pl_op;
1882 const condition = pl_op.operand;
1883 const switch_br = a.air.extraData(Air.SwitchBr, pl_op.payload);
1884
1885 var air_extra_index: usize = switch_br.end;
1886 for (0..switch_br.data.cases_len) |_| {
1887 const case = a.air.extraData(Air.SwitchBr.Case, air_extra_index);
1888 const case_body = a.air.extra[case.end + case.data.items_len ..][0..case.data.body_len];
1889 air_extra_index = case.end + case.data.items_len + case_body.len;
1890 try removeDeaths(a, to_remove, case_body);
1891 }
1892 { // else
1893 const else_body = a.air.extra[air_extra_index..][0..switch_br.data.else_body_len];
1894 try removeDeaths(a, to_remove, else_body);
1895 }
1896
1897 if (a.special.get(inst)) |liveness_extra_idx| {
1898 const else_death_count = a.extra.items[liveness_extra_idx];
1899 var read_idx = liveness_extra_idx + 1;
1900 var write_idx = read_idx; // write_idx <= read_idx always
1901 for (0..switch_br.data.cases_len) |_| {
1902 const case_death_count = a.extra.items[read_idx];
1903 const case_deaths = a.extra.items[read_idx + 1 ..][0..case_death_count];
1904 const new_death_count = removeExtraDeaths(to_remove, case_deaths);
1905 a.extra.items[write_idx] = new_death_count;
1906 if (write_idx < read_idx) {
1907 std.mem.copy(u32, a.extra.items[write_idx + 1 ..], a.extra.items[read_idx + 1 ..][0..new_death_count]);
1908 }
1909 read_idx += 1 + case_death_count;
1910 write_idx += 1 + new_death_count;
1911 }
1912 const else_deaths = a.extra.items[read_idx..][0..else_death_count];
1913 const new_else_death_count = removeExtraDeaths(to_remove, else_deaths);
1914 a.extra.items[liveness_extra_idx] = new_else_death_count;
1915 if (write_idx < read_idx) {
1916 std.mem.copy(u32, a.extra.items[write_idx..], a.extra.items[read_idx..][0..new_else_death_count]);
1917 }
1918 }
1919
1920 removeOperandDeaths(a, to_remove, inst, .{ condition, .none, .none });
1921 },
1922 .wasm_memory_grow => {
1923 const pl_op = inst_datas[inst].pl_op;
1924 removeOperandDeaths(a, to_remove, inst, .{ pl_op.operand, .none, .none });
1925 },
1926 }
1927}
1928
1929fn removeOperandDeaths(
1930 a: *Analysis,
1931 to_remove: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void),
1932 inst: Air.Inst.Index,
1933 operands: [bpi - 1]Air.Inst.Ref,
1934) void {
1935 const usize_index = (inst * bpi) / @bitSizeOf(usize);
1936
1937 const cur_tomb = @truncate(Bpi, a.tomb_bits[usize_index] >>
1938 @intCast(Log2Int(usize), (inst % (@bitSizeOf(usize) / bpi)) * bpi));
1939
1940 var toggle_bits: Bpi = 0;
1941
1942 for (operands, 0..) |op_ref, i| {
1943 const mask = @as(Bpi, 1) << @intCast(OperandInt, i);
1944 const op_int = @enumToInt(op_ref);
1945 if (op_int < Air.Inst.Ref.typed_value_map.len) continue;
1946 const operand: Air.Inst.Index = op_int - @intCast(u32, Air.Inst.Ref.typed_value_map.len);
1947 if ((cur_tomb & mask) != 0 and to_remove.contains(operand)) {
1948 log.debug("remove death of %{} in %{}", .{ operand, inst });
1949 toggle_bits ^= mask;
1950 }
1951 }
1952
1953 a.tomb_bits[usize_index] ^= @as(usize, toggle_bits) <<
1954 @intCast(Log2Int(usize), (inst % (@bitSizeOf(usize) / bpi)) * bpi);
1955}
1956
1957fn removeExtraDeaths(
1958 to_remove: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void),
1959 deaths: []Air.Inst.Index,
1960) u32 {
1961 var new_len = @intCast(u32, deaths.len);
1962 var i: usize = 0;
1963 while (i < new_len) {
1964 if (to_remove.contains(deaths[i])) {
1965 log.debug("remove extra death of %{}", .{deaths[i]});
1966 deaths[i] = deaths[new_len - 1];
1967 new_len -= 1;
1968 } else {
1969 i += 1;
1970 }
1971 }
1972 return new_len;
1973}
1974
1975const BigTombDeathRemover = struct {
1976 a: *Analysis,
1977 to_remove: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void),
1978 inst: Air.Inst.Index,
1979
1980 operands: [bpi - 1]Air.Inst.Ref = .{.none} ** (bpi - 1),
1981 next_oper: OperandInt = 0,
1982
1983 bit_index: u32 = 0,
1984 // Initialized once we finish the small tomb operands: see `feed`
1985 extra_start: u32 = undefined,
1986 extra_offset: u32 = 0,
1987
1988 fn init(a: *Analysis, to_remove: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void), inst: Air.Inst.Index) BigTombDeathRemover {
1989 return .{
1990 .a = a,
1991 .to_remove = to_remove,
1992 .inst = inst,
1993 };
1994 }
1995
1996 fn feed(dr: *BigTombDeathRemover, operand: Air.Inst.Ref) void {
1997 if (dr.next_oper < bpi - 1) {
1998 dr.operands[dr.next_oper] = operand;
1999 dr.next_oper += 1;
2000 if (dr.next_oper == bpi - 1) {
2001 removeOperandDeaths(dr.a, dr.to_remove, dr.inst, dr.operands);
2002 if (dr.a.special.get(dr.inst)) |idx| dr.extra_start = idx;
2003 }
2004 return;
2005 }
2006
2007 defer dr.bit_index += 1;
2008
2009 const op_int = @enumToInt(operand);
2010 if (op_int < Air.Inst.Ref.typed_value_map.len) return;
2011
2012 const op_inst: Air.Inst.Index = op_int - @intCast(u32, Air.Inst.Ref.typed_value_map.len);
2013
2014 while (dr.bit_index - dr.extra_offset * 31 >= 31) {
2015 dr.extra_offset += 1;
2016 }
2017 const dies = @truncate(u1, dr.a.extra.items[dr.extra_start + dr.extra_offset] >>
2018 @intCast(u5, dr.bit_index - dr.extra_offset * 31)) != 0;
2019
2020 if (dies and dr.to_remove.contains(op_inst)) {
2021 log.debug("remove big death of %{}", .{op_inst});
2022 dr.a.extra.items[dr.extra_start + dr.extra_offset] ^=
2023 (@as(u32, 1) << @intCast(u5, dr.bit_index - dr.extra_offset * 31));
2024 }
2025 }
2026
2027 fn finish(dr: *BigTombDeathRemover) void {
2028 if (dr.next_oper < bpi) {
2029 removeOperandDeaths(dr.a, dr.to_remove, dr.inst, dr.operands);
2030 }
2031 }
2032};
src/arch/aarch64/CodeGen.zig+8
......@@ -5000,9 +5000,17 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void {
50005000 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
50015001 const loop = self.air.extraData(Air.Block, ty_pl.payload);
50025002 const body = self.air.extra[loop.end..][0..loop.data.body_len];
5003 const liveness_loop = self.liveness.getLoop(inst);
50035004 const start_index = @intCast(u32, self.mir_instructions.len);
5005
50045006 try self.genBody(body);
50055007 try self.jump(start_index);
5008
5009 try self.ensureProcessDeathCapacity(liveness_loop.deaths.len);
5010 for (liveness_loop.deaths) |operand| {
5011 self.processDeath(operand);
5012 }
5013
50065014 return self.finishAirBookkeeping();
50075015}
50085016
src/arch/arm/CodeGen.zig+8
......@@ -4923,9 +4923,17 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void {
49234923 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
49244924 const loop = self.air.extraData(Air.Block, ty_pl.payload);
49254925 const body = self.air.extra[loop.end..][0..loop.data.body_len];
4926 const liveness_loop = self.liveness.getLoop(inst);
49264927 const start_index = @intCast(Mir.Inst.Index, self.mir_instructions.len);
4928
49274929 try self.genBody(body);
49284930 try self.jump(start_index);
4931
4932 try self.ensureProcessDeathCapacity(liveness_loop.deaths.len);
4933 for (liveness_loop.deaths) |operand| {
4934 self.processDeath(operand);
4935 }
4936
49294937 return self.finishAirBookkeeping();
49304938}
49314939
src/arch/sparc64/CodeGen.zig+8
......@@ -1750,9 +1750,17 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void {
17501750 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
17511751 const loop = self.air.extraData(Air.Block, ty_pl.payload);
17521752 const body = self.air.extra[loop.end .. loop.end + loop.data.body_len];
1753 const liveness_loop = self.liveness.getLoop(inst);
17531754 const start = @intCast(u32, self.mir_instructions.len);
1755
17541756 try self.genBody(body);
17551757 try self.jump(start);
1758
1759 try self.ensureProcessDeathCapacity(liveness_loop.deaths.len);
1760 for (liveness_loop.deaths) |operand| {
1761 self.processDeath(operand);
1762 }
1763
17561764 return self.finishAirBookkeeping();
17571765}
17581766
src/arch/wasm/CodeGen.zig+6
......@@ -3041,6 +3041,7 @@ fn airLoop(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
30413041 const ty_pl = func.air.instructions.items(.data)[inst].ty_pl;
30423042 const loop = func.air.extraData(Air.Block, ty_pl.payload);
30433043 const body = func.air.extra[loop.end..][0..loop.data.body_len];
3044 const liveness_loop = func.liveness.getLoop(inst);
30443045
30453046 // result type of loop is always 'noreturn', meaning we can always
30463047 // emit the wasm type 'block_empty'.
......@@ -3051,6 +3052,11 @@ fn airLoop(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
30513052 try func.addLabel(.br, 0);
30523053 try func.endBlock();
30533054
3055 try func.currentBranch().values.ensureUnusedCapacity(func.gpa, @intCast(u32, liveness_loop.deaths.len));
3056 for (liveness_loop.deaths) |death| {
3057 func.processDeath(Air.indexToRef(death));
3058 }
3059
30543060 func.finishAir(inst, .none, &.{});
30553061}
30563062
src/arch/x86_64/CodeGen.zig+7
......@@ -6185,6 +6185,7 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void {
61856185 const loop = self.air.extraData(Air.Block, ty_pl.payload);
61866186 const body = self.air.extra[loop.end..][0..loop.data.body_len];
61876187 const jmp_target = @intCast(u32, self.mir_instructions.len);
6188 const liveness_loop = self.liveness.getLoop(inst);
61886189
61896190 {
61906191 try self.branch_stack.append(.{});
......@@ -6208,6 +6209,12 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void {
62086209 try self.canonicaliseBranches(true, &dummy_branch, &branch, true, false);
62096210
62106211 _ = try self.asmJmpReloc(jmp_target);
6212
6213 try self.ensureProcessDeathCapacity(liveness_loop.deaths.len);
6214 for (liveness_loop.deaths) |operand| {
6215 self.processDeath(operand);
6216 }
6217
62116218 return self.finishAirBookkeeping();
62126219}
62136220
src/codegen/c.zig+29-58
......@@ -77,9 +77,8 @@ pub const LazyFnMap = std.AutoArrayHashMapUnmanaged(LazyFnKey, LazyFnValue);
7777const LoopDepth = u16;
7878const Local = struct {
7979 cty_idx: CType.Index,
80 /// How many loops the last definition was nested in.
81 loop_depth: LoopDepth,
8280 alignas: CType.AlignAs,
81 is_in_clone: bool,
8382
8483 pub fn getType(local: Local) LocalType {
8584 return .{ .cty_idx = local.cty_idx, .alignas = local.alignas };
......@@ -90,7 +89,6 @@ const LocalIndex = u16;
9089const LocalType = struct { cty_idx: CType.Index, alignas: CType.AlignAs };
9190const LocalsList = std.AutoArrayHashMapUnmanaged(LocalIndex, void);
9291const LocalsMap = std.AutoArrayHashMapUnmanaged(LocalType, LocalsList);
93const LocalsStack = std.ArrayListUnmanaged(LocalsMap);
9492
9593const ValueRenderLocation = enum {
9694 FunctionArgument,
......@@ -279,16 +277,16 @@ pub const Function = struct {
279277 /// Which locals are available for reuse, based on Type.
280278 /// Only locals in the last stack entry are available for reuse,
281279 /// other entries will become available on loop exit.
282 free_locals_stack: LocalsStack = .{},
283 free_locals_clone_depth: LoopDepth = 0,
280 free_locals_map: LocalsMap = .{},
281 is_in_clone: bool = false,
284282 /// Locals which will not be freed by Liveness. This is used after a
285 /// Function body is lowered in order to make `free_locals_stack` have
283 /// Function body is lowered in order to make `free_locals_map` have
286284 /// 100% of the locals within so that it can be used to render the block
287285 /// of variable declarations at the top of a function, sorted descending
288286 /// by type alignment.
289287 /// The value is whether the alloc is static or not.
290288 allocs: std.AutoArrayHashMapUnmanaged(LocalIndex, bool) = .{},
291 /// Needed for memory used by the keys of free_locals_stack entries.
289 /// Needed for memory used by the keys of free_locals_map entries.
292290 arena: std.heap.ArenaAllocator,
293291
294292 fn resolveInst(f: *Function, inst: Air.Inst.Ref) !CValue {
......@@ -323,18 +321,14 @@ pub const Function = struct {
323321 };
324322 }
325323
326 fn getFreeLocals(f: *Function) *LocalsMap {
327 return &f.free_locals_stack.items[f.free_locals_stack.items.len - 1];
328 }
329
330324 /// Skips the reuse logic.
331325 fn allocLocalValue(f: *Function, ty: Type, alignment: u32) !CValue {
332326 const gpa = f.object.dg.gpa;
333327 const target = f.object.dg.module.getTarget();
334328 try f.locals.append(gpa, .{
335329 .cty_idx = try f.typeToIndex(ty, .complete),
336 .loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1),
337330 .alignas = CType.AlignAs.init(alignment, ty.abiAlignment(target)),
331 .is_in_clone = f.is_in_clone,
338332 });
339333 return .{ .new_local = @intCast(LocalIndex, f.locals.items.len - 1) };
340334 }
......@@ -348,13 +342,11 @@ pub const Function = struct {
348342 /// Only allocates the local; does not print anything.
349343 fn allocAlignedLocal(f: *Function, ty: Type, _: CQualifiers, alignment: u32) !CValue {
350344 const target = f.object.dg.module.getTarget();
351 if (f.getFreeLocals().getPtr(.{
345 if (f.free_locals_map.getPtr(.{
352346 .cty_idx = try f.typeToIndex(ty, .complete),
353347 .alignas = CType.AlignAs.init(alignment, ty.abiAlignment(target)),
354348 })) |locals_list| {
355349 if (locals_list.popOrNull()) |local_entry| {
356 const local = &f.locals.items[local_entry.key];
357 local.loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1);
358350 return .{ .new_local = local_entry.key };
359351 }
360352 }
......@@ -485,10 +477,7 @@ pub const Function = struct {
485477 const gpa = f.object.dg.gpa;
486478 f.allocs.deinit(gpa);
487479 f.locals.deinit(gpa);
488 for (f.free_locals_stack.items) |*free_locals| {
489 deinitFreeLocalsMap(gpa, free_locals);
490 }
491 f.free_locals_stack.deinit(gpa);
480 deinitFreeLocalsMap(gpa, &f.free_locals_map);
492481 f.blocks.deinit(gpa);
493482 f.value_map.deinit();
494483 f.lazy_fns.deinit(gpa);
......@@ -2592,8 +2581,7 @@ pub fn genFunc(f: *Function) !void {
25922581 o.code_header.appendSliceAssumeCapacity("{\n ");
25932582 const empty_header_len = o.code_header.items.len;
25942583
2595 f.free_locals_stack.clearRetainingCapacity();
2596 try f.free_locals_stack.append(gpa, .{});
2584 f.free_locals_map.clearRetainingCapacity();
25972585
25982586 const main_body = f.air.getMainBody();
25992587 try genBody(f, main_body);
......@@ -2605,7 +2593,7 @@ pub fn genFunc(f: *Function) !void {
26052593 // Liveness analysis, however, locals from alloc instructions will be
26062594 // missing. These are added now to complete the map. Then we can sort by
26072595 // alignment, descending.
2608 const free_locals = f.getFreeLocals();
2596 const free_locals = &f.free_locals_map;
26092597 for (f.allocs.keys(), f.allocs.values()) |local_index, value| {
26102598 if (value) continue; // static
26112599 const local = f.locals.items[local_index];
......@@ -4630,30 +4618,16 @@ fn airLoop(f: *Function, inst: Air.Inst.Index) !CValue {
46304618 const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
46314619 const loop = f.air.extraData(Air.Block, ty_pl.payload);
46324620 const body = f.air.extra[loop.end..][0..loop.data.body_len];
4621 const liveness_loop = f.liveness.getLoop(inst);
46334622 const writer = f.object.writer();
46344623
4635 const gpa = f.object.dg.gpa;
4636 try f.free_locals_stack.insert(gpa, f.free_locals_stack.items.len - 1, .{});
4637
46384624 try writer.writeAll("for (;;) ");
46394625 try genBody(f, body);
46404626 try writer.writeByte('\n');
46414627
4642 var old_free_locals = f.free_locals_stack.pop();
4643 defer deinitFreeLocalsMap(gpa, &old_free_locals);
4644 const new_free_locals = f.getFreeLocals();
4645 var it = new_free_locals.iterator();
4646 while (it.next()) |entry| {
4647 const gop = try old_free_locals.getOrPut(gpa, entry.key_ptr.*);
4648 if (gop.found_existing) {
4649 try gop.value_ptr.ensureUnusedCapacity(gpa, entry.value_ptr.count());
4650 for (entry.value_ptr.keys()) |local_index| {
4651 gop.value_ptr.putAssumeCapacityNoClobber(local_index, {});
4652 }
4653 } else gop.value_ptr.* = entry.value_ptr.move();
4628 for (liveness_loop.deaths) |operand| {
4629 try die(f, inst, Air.indexToRef(operand));
46544630 }
4655 deinitFreeLocalsMap(gpa, new_free_locals);
4656 new_free_locals.* = old_free_locals.move();
46574631
46584632 return .none;
46594633}
......@@ -4673,7 +4647,7 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {
46734647 const gpa = f.object.dg.gpa;
46744648 var cloned_map = try f.value_map.clone();
46754649 defer cloned_map.deinit();
4676 var cloned_frees = try cloneFreeLocalsMap(gpa, f.getFreeLocals());
4650 var cloned_frees = try cloneFreeLocalsMap(gpa, &f.free_locals_map);
46774651 defer deinitFreeLocalsMap(gpa, &cloned_frees);
46784652
46794653 // Remember how many locals there were before entering the then branch so
......@@ -4684,8 +4658,8 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {
46844658 // that we can notice and make sure not to use them in the else branch.
46854659 // Any new allocs must be removed from the free list.
46864660 const pre_allocs_len = @intCast(LocalIndex, f.allocs.count());
4687 const pre_clone_depth = f.free_locals_clone_depth;
4688 f.free_locals_clone_depth = @intCast(LoopDepth, f.free_locals_stack.items.len);
4661 const was_in_clone = f.is_in_clone;
4662 f.is_in_clone = true;
46894663
46904664 for (liveness_condbr.then_deaths) |operand| {
46914665 try die(f, inst, Air.indexToRef(operand));
......@@ -4706,10 +4680,10 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {
47064680
47074681 f.value_map.deinit();
47084682 f.value_map = cloned_map.move();
4709 const free_locals = f.getFreeLocals();
4683 const free_locals = &f.free_locals_map;
47104684 deinitFreeLocalsMap(gpa, free_locals);
47114685 free_locals.* = cloned_frees.move();
4712 f.free_locals_clone_depth = pre_clone_depth;
4686 f.is_in_clone = was_in_clone;
47134687 for (liveness_condbr.else_deaths) |operand| {
47144688 try die(f, inst, Air.indexToRef(operand));
47154689 }
......@@ -4781,7 +4755,7 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
47814755 if (case_i != last_case_i) {
47824756 const old_value_map = f.value_map;
47834757 f.value_map = try old_value_map.clone();
4784 var free_locals = f.getFreeLocals();
4758 var free_locals = &f.free_locals_map;
47854759 const old_free_locals = free_locals.*;
47864760 free_locals.* = try cloneFreeLocalsMap(gpa, free_locals);
47874761
......@@ -4793,14 +4767,13 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
47934767 // we can notice and make sure not to use them in subsequent branches.
47944768 // Any new allocs must be removed from the free list.
47954769 const pre_allocs_len = @intCast(LocalIndex, f.allocs.count());
4796 const pre_clone_depth = f.free_locals_clone_depth;
4797 f.free_locals_clone_depth = @intCast(LoopDepth, f.free_locals_stack.items.len);
4770 const was_in_clone = f.is_in_clone;
4771 f.is_in_clone = true;
47984772
47994773 {
48004774 defer {
4801 f.free_locals_clone_depth = pre_clone_depth;
4775 f.is_in_clone = was_in_clone;
48024776 f.value_map.deinit();
4803 free_locals = f.getFreeLocals();
48044777 deinitFreeLocalsMap(gpa, free_locals);
48054778 f.value_map = old_value_map;
48064779 free_locals.* = old_free_locals;
......@@ -7870,8 +7843,8 @@ fn freeLocal(f: *Function, inst: Air.Inst.Index, local_index: LocalIndex, ref_in
78707843 const gpa = f.object.dg.gpa;
78717844 const local = &f.locals.items[local_index];
78727845 log.debug("%{d}: freeing t{d} (operand %{d})", .{ inst, local_index, ref_inst });
7873 if (local.loop_depth < f.free_locals_clone_depth) return;
7874 const gop = try f.free_locals_stack.items[local.loop_depth].getOrPut(gpa, local.getType());
7846 if (f.is_in_clone != local.is_in_clone) return;
7847 const gop = try f.free_locals_map.getOrPut(gpa, local.getType());
78757848 if (!gop.found_existing) gop.value_ptr.* = .{};
78767849 if (std.debug.runtime_safety) {
78777850 // If this trips, an unfreeable allocation was attempted to be freed.
......@@ -7935,23 +7908,21 @@ fn noticeBranchFrees(
79357908 pre_allocs_len: LocalIndex,
79367909 inst: Air.Inst.Index,
79377910) !void {
7938 const free_locals = f.getFreeLocals();
7939
79407911 for (f.locals.items[pre_locals_len..], pre_locals_len..) |*local, local_i| {
79417912 const local_index = @intCast(LocalIndex, local_i);
79427913 if (f.allocs.contains(local_index)) {
79437914 if (std.debug.runtime_safety) {
79447915 // new allocs are no longer freeable, so make sure they aren't in the free list
7945 if (free_locals.getPtr(local.getType())) |locals_list| {
7916 if (f.free_locals_map.getPtr(local.getType())) |locals_list| {
79467917 assert(!locals_list.contains(local_index));
79477918 }
79487919 }
79497920 continue;
79507921 }
79517922
7952 // free more deeply nested locals from other branches at current depth
7953 assert(local.loop_depth >= f.free_locals_stack.items.len - 1);
7954 local.loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1);
7923 // free cloned locals from other branches at current cloned-ness
7924 std.debug.assert(local.is_in_clone or !f.is_in_clone);
7925 local.is_in_clone = f.is_in_clone;
79557926 try freeLocal(f, inst, local_index, 0);
79567927 }
79577928
......@@ -7959,6 +7930,6 @@ fn noticeBranchFrees(
79597930 const local_index = @intCast(LocalIndex, local_i);
79607931 const local = &f.locals.items[local_index];
79617932 // new allocs are no longer freeable, so remove them from the free list
7962 if (free_locals.getPtr(local.getType())) |locals_list| _ = locals_list.swapRemove(local_index);
7933 if (f.free_locals_map.getPtr(local.getType())) |locals_list| _ = locals_list.swapRemove(local_index);
79637934 }
79647935}
src/print_air.zig+28-3
......@@ -267,9 +267,9 @@ const Writer = struct {
267267 .c_va_copy,
268268 => try w.writeTyOp(s, inst),
269269
270 .block,
271 .loop,
272 => try w.writeBlock(s, inst),
270 .block => try w.writeBlock(s, inst),
271
272 .loop => try w.writeLoop(s, inst),
273273
274274 .slice,
275275 .slice_elem_ptr,
......@@ -401,6 +401,31 @@ const Writer = struct {
401401 try s.writeAll("}");
402402 }
403403
404 fn writeLoop(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
405 const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
406 const extra = w.air.extraData(Air.Block, ty_pl.payload);
407 const body = w.air.extra[extra.end..][0..extra.data.body_len];
408 const liveness_loop = w.liveness.getLoop(inst);
409
410 try w.writeType(s, w.air.getRefType(ty_pl.ty));
411 if (w.skip_body) return s.writeAll(", ...");
412 try s.writeAll(", {\n");
413 const old_indent = w.indent;
414 w.indent += 2;
415 try w.writeBody(s, body);
416 if (liveness_loop.deaths.len != 0) {
417 try s.writeByteNTimes(' ', w.indent);
418 for (liveness_loop.deaths, 0..) |operand, i| {
419 if (i != 0) try s.writeAll(" ");
420 try s.print("%{d}!", .{operand});
421 }
422 try s.writeAll("\n");
423 }
424 w.indent = old_indent;
425 try s.writeByteNTimes(' ', w.indent);
426 try s.writeAll("}");
427 }
428
404429 fn writeAggregateInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
405430 const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
406431 const vector_ty = w.air.getRefType(ty_pl.ty);
test/behavior/const_slice_child.zig-1
......@@ -7,7 +7,6 @@ const expect = testing.expect;
77var argv: [*]const [*]const u8 = undefined;
88
99test "const slice child" {
10 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
1110 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
1211 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
1312 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
test/behavior/for.zig-2
......@@ -227,7 +227,6 @@ test "else continue outer for" {
227227
228228test "for loop with else branch" {
229229 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
230 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
231230
232231 {
233232 var x = [_]u32{ 1, 2 };
......@@ -377,7 +376,6 @@ test "raw pointer and slice" {
377376test "raw pointer and counter" {
378377 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
379378 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
380 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
381379 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
382380
383381 var buf: [10]u8 = undefined;
test/behavior/slice.zig-1
......@@ -238,7 +238,6 @@ test "C pointer" {
238238test "C pointer slice access" {
239239 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
240240 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
241 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
242241 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
243242
244243 var buf: [10]u32 = [1]u32{42} ** 10;