@@ -1792,6 +1792,7 @@ void swift::endLifetimeAtLeakingBlocks(SILValue value,
17921792 });
17931793}
17941794
1795+ // TODO: this currently fails to notify the pass with notifyNewInstruction.
17951796void swift::salvageDebugInfo (SILInstruction *I) {
17961797 if (!I)
17971798 return ;
@@ -1872,6 +1873,38 @@ void swift::salvageDebugInfo(SILInstruction *I) {
18721873 }
18731874}
18741875
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+
18751908IntegerLiteralInst *swift::optimizeBuiltinCanBeObjCClass (BuiltinInst *bi,
18761909 SILBuilder &builder) {
18771910 assert (bi->getBuiltinInfo ().ID == BuiltinValueKind::CanBeObjCClass);
0 commit comments