@@ -1420,6 +1420,13 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1420
1420
}
1421
1421
}
1422
1422
1423
+ void printForwardingOwnershipKind (OwnershipForwardingMixin *inst,
1424
+ SILValue op) {
1425
+ if (inst->getForwardingOwnershipKind () != op.getOwnershipKind ()) {
1426
+ *this << " , forwarding: @" << inst->getForwardingOwnershipKind ();
1427
+ }
1428
+ }
1429
+
1423
1430
void visitStoreInst (StoreInst *SI) {
1424
1431
*this << Ctx.getID (SI->getSrc ()) << " to " ;
1425
1432
printStoreOwnershipQualifier (SI->getOwnershipQualifier ());
@@ -1465,8 +1472,8 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1465
1472
*this << " [delegatingselfallocated] " ;
1466
1473
break ;
1467
1474
}
1468
-
1469
1475
*this << getIDAndType (MU->getOperand ());
1476
+ printForwardingOwnershipKind (MU, MU->getOperand ());
1470
1477
}
1471
1478
1472
1479
void visitMarkFunctionEscapeInst (MarkFunctionEscapeInst *MFE) {
@@ -1516,6 +1523,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1516
1523
1517
1524
void visitUnconditionalCheckedCastInst (UnconditionalCheckedCastInst *CI) {
1518
1525
*this << getIDAndType (CI->getOperand ()) << " to " << CI->getTargetFormalType ();
1526
+ printForwardingOwnershipKind (CI, CI->getOperand ());
1519
1527
}
1520
1528
1521
1529
void visitCheckedCastBranchInst (CheckedCastBranchInst *CI) {
@@ -1564,6 +1572,9 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1564
1572
1565
1573
void printUncheckedConversionInst (ConversionInst *CI, SILValue operand) {
1566
1574
*this << getIDAndType (operand) << " to " << CI->getType ();
1575
+ if (auto *ofci = dyn_cast<OwnershipForwardingConversionInst>(CI)) {
1576
+ printForwardingOwnershipKind (ofci, ofci->getOperand (0 ));
1577
+ }
1567
1578
}
1568
1579
1569
1580
void visitUncheckedOwnershipConversionInst (
@@ -1578,6 +1589,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1578
1589
if (CI->withoutActuallyEscaping ())
1579
1590
*this << " [without_actually_escaping] " ;
1580
1591
*this << CI->getType ();
1592
+ printForwardingOwnershipKind (CI, CI->getOperand ());
1581
1593
}
1582
1594
void visitConvertEscapeToNoEscapeInst (ConvertEscapeToNoEscapeInst *CI) {
1583
1595
*this << (CI->isLifetimeGuaranteed () ? " " : " [not_guaranteed] " )
@@ -1661,10 +1673,12 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1661
1673
void visitRefToBridgeObjectInst (RefToBridgeObjectInst *I) {
1662
1674
*this << getIDAndType (I->getConverted ()) << " , "
1663
1675
<< getIDAndType (I->getBitsOperand ());
1676
+ printForwardingOwnershipKind (I, I->getConverted ());
1664
1677
}
1665
1678
1666
1679
void visitBridgeObjectToRefInst (BridgeObjectToRefInst *I) {
1667
1680
printUncheckedConversionInst (I, I->getOperand ());
1681
+ printForwardingOwnershipKind (I, I->getOperand ());
1668
1682
}
1669
1683
void visitBridgeObjectToWordInst (BridgeObjectToWordInst *I) {
1670
1684
printUncheckedConversionInst (I, I->getOperand ());
@@ -1748,6 +1762,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1748
1762
<< SILDeclRef (UI->getElement (), SILDeclRef::Kind::EnumElement);
1749
1763
if (UI->hasOperand ()) {
1750
1764
*this << " , " << getIDAndType (UI->getOperand ());
1765
+ printForwardingOwnershipKind (UI, UI->getOperand ());
1751
1766
}
1752
1767
}
1753
1768
@@ -1759,6 +1774,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1759
1774
void visitUncheckedEnumDataInst (UncheckedEnumDataInst *UDAI) {
1760
1775
*this << getIDAndType (UDAI->getOperand ()) << " , "
1761
1776
<< SILDeclRef (UDAI->getElement (), SILDeclRef::Kind::EnumElement);
1777
+ printForwardingOwnershipKind (UDAI, UDAI->getOperand ());
1762
1778
}
1763
1779
1764
1780
void visitUncheckedTakeEnumDataAddrInst (UncheckedTakeEnumDataAddrInst *UDAI) {
@@ -1773,6 +1789,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1773
1789
1774
1790
void visitTupleExtractInst (TupleExtractInst *EI) {
1775
1791
*this << getIDAndType (EI->getOperand ()) << " , " << EI->getFieldIndex ();
1792
+ printForwardingOwnershipKind (EI, EI->getOperand ());
1776
1793
}
1777
1794
1778
1795
void visitTupleElementAddrInst (TupleElementAddrInst *EI) {
@@ -1782,6 +1799,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1782
1799
*this << getIDAndType (EI->getOperand ()) << " , #" ;
1783
1800
printFullContext (EI->getField ()->getDeclContext (), PrintState.OS );
1784
1801
*this << EI->getField ()->getName ().get ();
1802
+ printForwardingOwnershipKind (EI, EI->getOperand ());
1785
1803
}
1786
1804
void visitStructElementAddrInst (StructElementAddrInst *EI) {
1787
1805
*this << getIDAndType (EI->getOperand ()) << " , #" ;
@@ -1802,10 +1820,12 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1802
1820
1803
1821
void visitDestructureStructInst (DestructureStructInst *DSI) {
1804
1822
*this << getIDAndType (DSI->getOperand ());
1823
+ printForwardingOwnershipKind (DSI, DSI->getOperand ());
1805
1824
}
1806
1825
1807
1826
void visitDestructureTupleInst (DestructureTupleInst *DTI) {
1808
1827
*this << getIDAndType (DTI->getOperand ());
1828
+ printForwardingOwnershipKind (DTI, DTI->getOperand ());
1809
1829
}
1810
1830
1811
1831
void printMethodInst (MethodInst *I, SILValue Operand) {
@@ -1859,6 +1879,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1859
1879
}
1860
1880
void visitOpenExistentialRefInst (OpenExistentialRefInst *OI) {
1861
1881
*this << getIDAndType (OI->getOperand ()) << " to " << OI->getType ();
1882
+ printForwardingOwnershipKind (OI, OI->getOperand ());
1862
1883
}
1863
1884
void visitOpenExistentialMetatypeInst (OpenExistentialMetatypeInst *OI) {
1864
1885
*this << getIDAndType (OI->getOperand ()) << " to " << OI->getType ();
@@ -1868,9 +1889,11 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1868
1889
}
1869
1890
void visitOpenExistentialBoxValueInst (OpenExistentialBoxValueInst *OI) {
1870
1891
*this << getIDAndType (OI->getOperand ()) << " to " << OI->getType ();
1892
+ printForwardingOwnershipKind (OI, OI->getOperand ());
1871
1893
}
1872
1894
void visitOpenExistentialValueInst (OpenExistentialValueInst *OI) {
1873
1895
*this << getIDAndType (OI->getOperand ()) << " to " << OI->getType ();
1896
+ printForwardingOwnershipKind (OI, OI->getOperand ());
1874
1897
}
1875
1898
void visitInitExistentialAddrInst (InitExistentialAddrInst *AEI) {
1876
1899
*this << getIDAndType (AEI->getOperand ()) << " , $"
@@ -1886,6 +1909,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1886
1909
*this << getIDAndType (AEI->getOperand ()) << " : $"
1887
1910
<< AEI->getFormalConcreteType () << " , " << AEI->getType ();
1888
1911
printConformances (AEI->getConformances ());
1912
+ printForwardingOwnershipKind (AEI, AEI->getOperand ());
1889
1913
}
1890
1914
void visitInitExistentialMetatypeInst (InitExistentialMetatypeInst *EMI) {
1891
1915
*this << getIDAndType (EMI->getOperand ()) << " , " << EMI->getType ();
@@ -1939,6 +1963,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
1939
1963
void visitMarkDependenceInst (MarkDependenceInst *MDI) {
1940
1964
*this << getIDAndType (MDI->getValue ()) << " on "
1941
1965
<< getIDAndType (MDI->getBase ());
1966
+ printForwardingOwnershipKind (MDI, MDI->getValue ());
1942
1967
}
1943
1968
void visitCopyBlockInst (CopyBlockInst *RI) {
1944
1969
*this << getIDAndType (RI->getOperand ());
@@ -2133,6 +2158,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
2133
2158
2134
2159
void visitSwitchEnumInst (SwitchEnumInst *SOI) {
2135
2160
printSwitchEnumInst (SOI);
2161
+ printForwardingOwnershipKind (SOI, SOI->getOperand ());
2136
2162
}
2137
2163
void visitSwitchEnumAddrInst (SwitchEnumAddrInst *SOI) {
2138
2164
printSwitchEnumInst (SOI);
@@ -2156,6 +2182,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
2156
2182
2157
2183
void visitSelectEnumInst (SelectEnumInst *SEI) {
2158
2184
printSelectEnumInst (SEI);
2185
+ printForwardingOwnershipKind (SEI, SEI->getOperand ());
2159
2186
}
2160
2187
void visitSelectEnumAddrInst (SelectEnumAddrInst *SEI) {
2161
2188
printSelectEnumInst (SEI);
@@ -2174,6 +2201,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
2174
2201
*this << " , default " << Ctx.getID (SVI->getDefaultResult ());
2175
2202
2176
2203
*this << " : " << SVI->getType ();
2204
+ printForwardingOwnershipKind (SVI, SVI->getOperand ());
2177
2205
}
2178
2206
2179
2207
void visitDynamicMethodBranchInst (DynamicMethodBranchInst *DMBI) {
@@ -2411,6 +2439,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
2411
2439
*this << " as " ;
2412
2440
*this << dfei->getType ();
2413
2441
}
2442
+ printForwardingOwnershipKind (dfei, dfei->getOperand ());
2414
2443
}
2415
2444
2416
2445
void visitLinearFunctionExtractInst (LinearFunctionExtractInst *lfei) {
@@ -2425,6 +2454,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
2425
2454
}
2426
2455
*this << " ] " ;
2427
2456
*this << getIDAndType (lfei->getOperand ());
2457
+ printForwardingOwnershipKind (lfei, lfei->getOperand ());
2428
2458
}
2429
2459
2430
2460
void visitDifferentiabilityWitnessFunctionInst (
0 commit comments