Skip to content

Commit c632c0d

Browse files
committed
Add debug msgs in copy value opts
1 parent 4730a33 commit c632c0d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/SILOptimizer/SemanticARC/CopyValueOpts.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ using namespace swift::semanticarc;
6969
// TODO: This needs a better name.
7070
bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
7171
CopyValueInst *cvi) {
72+
LLVM_DEBUG(llvm::dbgs() << "Looking at ");
73+
LLVM_DEBUG(cvi->dump());
74+
7275
// All mandatory copy optimization is handled by CanonicalizeOSSALifetime,
7376
// which knows how to preserve lifetimes for debugging.
7477
if (ctx.onlyMandatoryOpts)
@@ -82,8 +85,10 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
8285
//
8386
// NOTE: We can get multiple introducers if our copy_value's operand
8487
// 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");
8690
return false;
91+
}
8792

8893
// Then go over all of our uses and see if the value returned by our copy
8994
// value forms a dead live range or a live range that would be dead if it was
@@ -96,6 +101,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
96101
lr.hasUnknownConsumingUse(ctx.assumingAtFixedPoint);
97102
if (hasUnknownConsumingUseState ==
98103
OwnershipLiveRange::HasConsumingUse_t::Yes) {
104+
LLVM_DEBUG(llvm::dbgs() << "Found unknown consuming uses\n");
99105
return false;
100106
}
101107

@@ -192,6 +198,8 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
192198
return !borrowScope.areUsesWithinExtendedScope(
193199
lr.getAllConsumingUses(), nullptr);
194200
})) {
201+
LLVM_DEBUG(llvm::dbgs() << "copy_value is extending borrow introducer "
202+
"lifetime, bailing out\n");
195203
return false;
196204
}
197205
}

0 commit comments

Comments
 (0)