@@ -69,6 +69,9 @@ using namespace swift::semanticarc;
69
69
// TODO: This needs a better name.
70
70
bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization (
71
71
CopyValueInst *cvi) {
72
+ LLVM_DEBUG (llvm::dbgs () << " Looking at " );
73
+ LLVM_DEBUG (cvi->dump ());
74
+
72
75
// All mandatory copy optimization is handled by CanonicalizeOSSALifetime,
73
76
// which knows how to preserve lifetimes for debugging.
74
77
if (ctx.onlyMandatoryOpts )
@@ -82,8 +85,10 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
82
85
//
83
86
// NOTE: We can get multiple introducers if our copy_value's operand
84
87
// value runs through a phi or an aggregate forming instruction.
85
- if (!getAllBorrowIntroducingValues (cvi->getOperand (), borrowScopeIntroducers))
88
+ if (!getAllBorrowIntroducingValues (cvi->getOperand (), borrowScopeIntroducers)) {
89
+ LLVM_DEBUG (llvm::dbgs () << " Did not find all borrow introducers\n " );
86
90
return false ;
91
+ }
87
92
88
93
// Then go over all of our uses and see if the value returned by our copy
89
94
// value forms a dead live range or a live range that would be dead if it was
@@ -96,6 +101,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
96
101
lr.hasUnknownConsumingUse (ctx.assumingAtFixedPoint );
97
102
if (hasUnknownConsumingUseState ==
98
103
OwnershipLiveRange::HasConsumingUse_t::Yes) {
104
+ LLVM_DEBUG (llvm::dbgs () << " Found unknown consuming uses\n " );
99
105
return false ;
100
106
}
101
107
@@ -192,6 +198,8 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
192
198
return !borrowScope.areUsesWithinExtendedScope (
193
199
lr.getAllConsumingUses (), nullptr );
194
200
})) {
201
+ LLVM_DEBUG (llvm::dbgs () << " copy_value is extending borrow introducer "
202
+ " lifetime, bailing out\n " );
195
203
return false ;
196
204
}
197
205
}
0 commit comments