@@ -1077,7 +1077,8 @@ void swift::copyLiveUse(Operand *use, InstModCallbacks &instModCallbacks) {
1077
1077
// / Revisit the def-use chain of currentDef. Mark unneeded original
1078
1078
// / copies and destroys for deletion. Insert new copies for interior uses that
1079
1079
// / require ownership of the used operand.
1080
- void CanonicalizeOSSALifetime::rewriteCopies () {
1080
+ void CanonicalizeOSSALifetime::rewriteCopies (
1081
+ SmallVectorImpl<DestroyValueInst *> const &newDestroys) {
1081
1082
assert (getCurrentDef ()->getOwnershipKind () == OwnershipKind::Owned);
1082
1083
1083
1084
InstructionSetVector instsToDelete (getCurrentDef ()->getFunction ());
@@ -1163,11 +1164,17 @@ void CanonicalizeOSSALifetime::rewriteCopies() {
1163
1164
assert (!consumes.hasUnclaimedConsumes ());
1164
1165
1165
1166
if (pruneDebugMode) {
1167
+ for (auto *destroy : newDestroys) {
1168
+ liveness->updateForUse (destroy, /* lifetimeEnding=*/ true );
1169
+ }
1166
1170
for (auto *dvi : debugValues) {
1167
- if (!liveness->isWithinBoundary (dvi)) {
1168
- LLVM_DEBUG (llvm::dbgs () << " Removing debug_value: " << *dvi);
1169
- deleter.forceDelete (dvi);
1171
+ if (liveness->areUsesWithinBoundary (
1172
+ {&dvi->getOperandRef ()},
1173
+ deadEndBlocksAnalysis->get (getCurrentDef ()->getFunction ()))) {
1174
+ continue ;
1170
1175
}
1176
+ LLVM_DEBUG (llvm::dbgs () << " Removing debug_value: " << *dvi);
1177
+ deleter.forceDelete (dvi);
1171
1178
}
1172
1179
}
1173
1180
@@ -1243,7 +1250,7 @@ void CanonicalizeOSSALifetime::rewriteLifetimes() {
1243
1250
// Step 5: insert destroys and record consumes
1244
1251
insertDestroysOnBoundary (extendedBoundary, newDestroys);
1245
1252
// Step 6: rewrite copies and delete extra destroys
1246
- rewriteCopies ();
1253
+ rewriteCopies (newDestroys );
1247
1254
1248
1255
clear ();
1249
1256
}
0 commit comments