@@ -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,11 @@ 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 (),
89
+ borrowScopeIntroducers)) {
90
+ LLVM_DEBUG (llvm::dbgs () << " Did not find all borrow introducers\n " );
86
91
return false ;
92
+ }
87
93
88
94
// Then go over all of our uses and see if the value returned by our copy
89
95
// value forms a dead live range or a live range that would be dead if it was
@@ -96,6 +102,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
96
102
lr.hasUnknownConsumingUse (ctx.assumingAtFixedPoint );
97
103
if (hasUnknownConsumingUseState ==
98
104
OwnershipLiveRange::HasConsumingUse_t::Yes) {
105
+ LLVM_DEBUG (llvm::dbgs () << " Found unknown consuming uses\n " );
99
106
return false ;
100
107
}
101
108
@@ -192,6 +199,8 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
192
199
return !borrowScope.areUsesWithinExtendedScope (
193
200
lr.getAllConsumingUses (), nullptr );
194
201
})) {
202
+ LLVM_DEBUG (llvm::dbgs () << " copy_value is extending borrow introducer "
203
+ " lifetime, bailing out\n " );
195
204
return false ;
196
205
}
197
206
}
0 commit comments