|
1495 | 1495 | ) |
1496 | 1496 | ) |
1497 | 1497 | ) |
| 1498 | + |
| 1499 | +;; The type $A is public because it is on an exported global. As a result we |
| 1500 | +;; cannot remove the unused i32 field from its child or grandchild. |
| 1501 | +(module |
| 1502 | + ;; CHECK: (type $A (sub (struct (field (mut i32))))) |
| 1503 | + (type $A (sub (struct (field (mut i32))))) |
| 1504 | + ;; CHECK: (type $B (sub $A (struct (field (mut i32))))) |
| 1505 | + (type $B (sub $A (struct (field (mut i32))))) |
| 1506 | + ;; CHECK: (type $C (sub $B (struct (field (mut i32))))) |
| 1507 | + (type $C (sub $B (struct (field (mut i32))))) |
| 1508 | + |
| 1509 | + ;; Use $C so it isn't removed trivially, which also keeps $B alive as its |
| 1510 | + ;; super. |
| 1511 | + ;; CHECK: (global $global (ref $A) (struct.new_default $C)) |
| 1512 | + (global $global (ref $A) (struct.new_default $C)) |
| 1513 | + |
| 1514 | + ;; CHECK: (export "global" (global $global)) |
| 1515 | + (export "global" (global $global)) |
| 1516 | +) |
| 1517 | + |
| 1518 | +;; As above, but now there is an f64 field on $C that can be removed, since it |
| 1519 | +;; is not on the parents. |
| 1520 | +(module |
| 1521 | + ;; CHECK: (type $A (sub (struct (field (mut i32))))) |
| 1522 | + (type $A (sub (struct (field (mut i32))))) |
| 1523 | + ;; CHECK: (rec |
| 1524 | + ;; CHECK-NEXT: (type $B (sub $A (struct (field (mut i32))))) |
| 1525 | + (type $B (sub $A (struct (field (mut i32))))) |
| 1526 | + ;; CHECK: (type $C (sub $B (struct (field (mut i32))))) |
| 1527 | + (type $C (sub $B (struct (field (mut i32)) (field (mut f64))))) |
| 1528 | + |
| 1529 | + ;; CHECK: (global $global (ref $A) (struct.new_default $C)) |
| 1530 | + (global $global (ref $A) (struct.new_default $C)) |
| 1531 | + |
| 1532 | + ;; CHECK: (export "global" (global $global)) |
| 1533 | + (export "global" (global $global)) |
| 1534 | +) |
| 1535 | + |
| 1536 | +;; As above, but the f64 field is now on $B as well. We can still remove it. |
| 1537 | +(module |
| 1538 | + ;; CHECK: (type $A (sub (struct (field (mut i32))))) |
| 1539 | + (type $A (sub (struct (field (mut i32))))) |
| 1540 | + ;; CHECK: (rec |
| 1541 | + ;; CHECK-NEXT: (type $B (sub $A (struct (field (mut i32))))) |
| 1542 | + (type $B (sub $A (struct (field (mut i32)) (field (mut f64))))) |
| 1543 | + ;; CHECK: (type $C (sub $B (struct (field (mut i32))))) |
| 1544 | + (type $C (sub $B (struct (field (mut i32)) (field (mut f64))))) |
| 1545 | + |
| 1546 | + ;; CHECK: (global $global (ref $A) (struct.new_default $C)) |
| 1547 | + (global $global (ref $A) (struct.new_default $C)) |
| 1548 | + |
| 1549 | + ;; CHECK: (export "global" (global $global)) |
| 1550 | + (export "global" (global $global)) |
| 1551 | +) |
| 1552 | + |
| 1553 | +;; As above, but now $B is public as well. Now we cannot remove the f64. |
| 1554 | +(module |
| 1555 | + ;; CHECK: (type $A (sub (struct (field (mut i32))))) |
| 1556 | + (type $A (sub (struct (field (mut i32))))) |
| 1557 | + ;; CHECK: (type $B (sub $A (struct (field (mut i32)) (field (mut f64))))) |
| 1558 | + (type $B (sub $A (struct (field (mut i32)) (field (mut f64))))) |
| 1559 | + ;; CHECK: (type $C (sub $B (struct (field (mut i32)) (field (mut f64))))) |
| 1560 | + (type $C (sub $B (struct (field (mut i32)) (field (mut f64))))) |
| 1561 | + |
| 1562 | + ;; CHECK: (global $global (ref $A) (struct.new_default $C)) |
| 1563 | + (global $global (ref $A) (struct.new_default $C)) |
| 1564 | + |
| 1565 | + ;; CHECK: (global $globalB (ref $B) (struct.new_default $C)) |
| 1566 | + (global $globalB (ref $B) (struct.new_default $C)) |
| 1567 | + |
| 1568 | + ;; CHECK: (export "global" (global $global)) |
| 1569 | + (export "global" (global $global)) |
| 1570 | + |
| 1571 | + ;; CHECK: (export "globalB" (global $globalB)) |
| 1572 | + (export "globalB" (global $globalB)) |
| 1573 | +) |
| 1574 | + |
0 commit comments