|
1405 | 1405 | ) |
1406 | 1406 | ) |
1407 | 1407 | ) |
| 1408 | + |
| 1409 | +;; Public types cannot be optimized. The function type here is public as the |
| 1410 | +;; function is exported, and so the entire rec group is public, and cannot be |
| 1411 | +;; modified. We cannot even optimize $child3 which is outside of the rec group, |
| 1412 | +;; because its parent is inside. However, we can optimize $unrelated which is |
| 1413 | +;; unrelated to them (and so we can remove the field there). |
| 1414 | +(module |
| 1415 | + (rec |
| 1416 | + ;; CHECK: (rec |
| 1417 | + ;; CHECK-NEXT: (type $parent (sub (struct (field (ref func))))) |
| 1418 | + (type $parent (sub (struct (field (ref func))))) |
| 1419 | + ;; CHECK: (type $child1 (sub $parent (struct (field (ref func))))) |
| 1420 | + (type $child1 (sub $parent (struct (field (ref func))))) |
| 1421 | + ;; CHECK: (type $child2 (sub $parent (struct (field (ref func))))) |
| 1422 | + (type $child2 (sub $parent (struct (field (ref func))))) |
| 1423 | + |
| 1424 | + ;; CHECK: (type $func (func (param (ref $child2)))) |
| 1425 | + (type $func (func (param $child2 (ref $child2)))) |
| 1426 | + ) |
| 1427 | + |
| 1428 | + ;; CHECK: (rec |
| 1429 | + ;; CHECK-NEXT: (type $unrelated (sub (struct))) |
| 1430 | + |
| 1431 | + ;; CHECK: (type $child3 (sub $parent (struct (field (ref func))))) |
| 1432 | + (type $child3 (sub $parent (struct (field (ref func))))) |
| 1433 | + |
| 1434 | + (type $unrelated (sub (struct (field (ref func))))) |
| 1435 | + |
| 1436 | + ;; CHECK: (elem declare func $func) |
| 1437 | + |
| 1438 | + ;; CHECK: (export "func" (func $func)) |
| 1439 | + |
| 1440 | + ;; CHECK: (func $func (type $func) (param $child2 (ref $child2)) |
| 1441 | + ;; CHECK-NEXT: (drop |
| 1442 | + ;; CHECK-NEXT: (struct.new $parent |
| 1443 | + ;; CHECK-NEXT: (ref.func $func) |
| 1444 | + ;; CHECK-NEXT: ) |
| 1445 | + ;; CHECK-NEXT: ) |
| 1446 | + ;; CHECK-NEXT: (drop |
| 1447 | + ;; CHECK-NEXT: (struct.new $child1 |
| 1448 | + ;; CHECK-NEXT: (ref.func $func) |
| 1449 | + ;; CHECK-NEXT: ) |
| 1450 | + ;; CHECK-NEXT: ) |
| 1451 | + ;; CHECK-NEXT: (drop |
| 1452 | + ;; CHECK-NEXT: (struct.new $child2 |
| 1453 | + ;; CHECK-NEXT: (ref.func $func) |
| 1454 | + ;; CHECK-NEXT: ) |
| 1455 | + ;; CHECK-NEXT: ) |
| 1456 | + ;; CHECK-NEXT: (drop |
| 1457 | + ;; CHECK-NEXT: (struct.new $child3 |
| 1458 | + ;; CHECK-NEXT: (ref.func $func) |
| 1459 | + ;; CHECK-NEXT: ) |
| 1460 | + ;; CHECK-NEXT: ) |
| 1461 | + ;; CHECK-NEXT: (drop |
| 1462 | + ;; CHECK-NEXT: (struct.new_default $unrelated) |
| 1463 | + ;; CHECK-NEXT: ) |
| 1464 | + ;; CHECK-NEXT: ) |
| 1465 | + (func $func (export "func") (type $func) (param $child2 (ref $child2)) |
| 1466 | + ;; Create all the types. Note that the value here is non-nullable, as is the |
| 1467 | + ;; field, so if we remove the field by mistake in GTO but leave it during |
| 1468 | + ;; TypeUpdater, we'd error (on providing a default value for a non-nullable |
| 1469 | + ;; field). |
| 1470 | + (drop |
| 1471 | + (struct.new $parent |
| 1472 | + (ref.func $func) |
| 1473 | + ) |
| 1474 | + ) |
| 1475 | + (drop |
| 1476 | + (struct.new $child1 |
| 1477 | + (ref.func $func) |
| 1478 | + ) |
| 1479 | + ) |
| 1480 | + (drop |
| 1481 | + (struct.new $child2 |
| 1482 | + (ref.func $func) |
| 1483 | + ) |
| 1484 | + ) |
| 1485 | + (drop |
| 1486 | + (struct.new $child3 |
| 1487 | + (ref.func $func) |
| 1488 | + ) |
| 1489 | + ) |
| 1490 | + ;; We can optimize this one, and no other. |
| 1491 | + (drop |
| 1492 | + (struct.new $unrelated |
| 1493 | + (ref.func $func) |
| 1494 | + ) |
| 1495 | + ) |
| 1496 | + ) |
| 1497 | +) |
0 commit comments