@@ -1792,6 +1792,7 @@ void swift::endLifetimeAtLeakingBlocks(SILValue value,
1792
1792
});
1793
1793
}
1794
1794
1795
+ // TODO: this currently fails to notify the pass with notifyNewInstruction.
1795
1796
void swift::salvageDebugInfo (SILInstruction *I) {
1796
1797
if (!I)
1797
1798
return ;
@@ -1872,6 +1873,38 @@ void swift::salvageDebugInfo(SILInstruction *I) {
1872
1873
}
1873
1874
}
1874
1875
1876
+ // TODO: this currently fails to notify the pass with notifyNewInstruction.
1877
+ void swift::createDebugFragments (SILValue oldValue, Projection proj,
1878
+ SILValue newValue) {
1879
+ if (proj.getKind () != ProjectionKind::Struct)
1880
+ return ;
1881
+
1882
+ for (auto *use : getDebugUses (oldValue)) {
1883
+ auto debugVal = dyn_cast<DebugValueInst>(use->getUser ());
1884
+ if (!debugVal)
1885
+ continue ;
1886
+
1887
+ // Can't create a fragment of a fragment.
1888
+ auto varInfo = debugVal->getVarInfo ();
1889
+ if (!varInfo || varInfo->DIExpr .hasFragment ())
1890
+ continue ;
1891
+
1892
+ SILType baseType = oldValue->getType ();
1893
+
1894
+ // Copy VarInfo and add the corresponding fragment DIExpression.
1895
+ SILDebugVariable newVarInfo = *varInfo;
1896
+ newVarInfo.DIExpr .append (
1897
+ SILDebugInfoExpression::createFragment (proj.getVarDecl (baseType)));
1898
+
1899
+ if (!newVarInfo.Type )
1900
+ newVarInfo.Type = baseType;
1901
+
1902
+ // Create a new debug_value
1903
+ SILBuilder (debugVal, debugVal->getDebugScope ())
1904
+ .createDebugValue (debugVal->getLoc (), newValue, newVarInfo);
1905
+ }
1906
+ }
1907
+
1875
1908
IntegerLiteralInst *swift::optimizeBuiltinCanBeObjCClass (BuiltinInst *bi,
1876
1909
SILBuilder &builder) {
1877
1910
assert (bi->getBuiltinInfo ().ID == BuiltinValueKind::CanBeObjCClass);
0 commit comments