File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -279,14 +279,23 @@ bool TempLValueOptPass::combineCopyAndDestroy(CopyAddrInst *copyInst) {
279
279
280
280
// Check if the destroy_addr is after the copy_addr and if there are no
281
281
// memory accesses between them.
282
+ SmallVector<DebugValueAddrInst *, 4 > debugInsts;
282
283
for (auto iter = std::next (copyInst->getIterator ());
283
284
iter != block->end (); ++iter) {
284
285
SILInstruction *inst = &*iter;
285
286
if (inst == destroy) {
286
287
copyInst->setIsTakeOfSrc (IsTake);
287
288
destroy->eraseFromParent ();
289
+ // Cleanup all debug_value_addr of the copy src btw the copy and destroy
290
+ for (auto debugInst : debugInsts) {
291
+ debugInst->eraseFromParent ();
292
+ }
288
293
return true ;
289
294
}
295
+ if (auto *debugInst = dyn_cast<DebugValueAddrInst>(inst)) {
296
+ if (debugInst->getOperand () == copyInst->getSrc ())
297
+ debugInsts.push_back (debugInst);
298
+ }
290
299
if (inst->mayReadOrWriteMemory ())
291
300
return false ;
292
301
}
Original file line number Diff line number Diff line change @@ -282,3 +282,21 @@ bb0(%0 :@owned $Child):
282
282
%res = tuple ()
283
283
return %res : $()
284
284
}
285
+
286
+ // CHECK-LABEL: sil [ossa] @cleanup_debuginsts :
287
+ // CHECK: copy_addr [take]
288
+ // CHECK-NOT: debug_value_addr
289
+ // CHECK-LABEL: } // end sil function 'cleanup_debuginsts'
290
+ sil [ossa] @cleanup_debuginsts : $@convention(thin) <T> (@in T) -> () {
291
+ bb0(%0 : $*T):
292
+ %2 = alloc_stack $T
293
+ debug_value_addr %0 : $*T
294
+ copy_addr %0 to [initialization] %2 : $*T
295
+ debug_value_addr %0 : $*T
296
+ destroy_addr %0 : $*T
297
+ destroy_addr %2 : $*T
298
+ dealloc_stack %2 : $*T
299
+ %78 = tuple ()
300
+ return %78 : $()
301
+ }
302
+
You can’t perform that action at this time.
0 commit comments