Skip to content

Commit 24aa329

Browse files
committed
[NFC] Add debug msgs in copy value opts
1 parent 90c5b80 commit 24aa329

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/SILOptimizer/SemanticARC/CopyValueOpts.cpp

Lines changed: 10 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,11 @@ 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(),
89+
borrowScopeIntroducers)) {
90+
LLVM_DEBUG(llvm::dbgs() << "Did not find all borrow introducers\n");
8691
return false;
92+
}
8793

8894
// Then go over all of our uses and see if the value returned by our copy
8995
// value forms a dead live range or a live range that would be dead if it was
@@ -96,6 +102,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
96102
lr.hasUnknownConsumingUse(ctx.assumingAtFixedPoint);
97103
if (hasUnknownConsumingUseState ==
98104
OwnershipLiveRange::HasConsumingUse_t::Yes) {
105+
LLVM_DEBUG(llvm::dbgs() << "Found unknown consuming uses\n");
99106
return false;
100107
}
101108

@@ -192,6 +199,8 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
192199
return !borrowScope.areUsesWithinExtendedScope(
193200
lr.getAllConsumingUses(), nullptr);
194201
})) {
202+
LLVM_DEBUG(llvm::dbgs() << "copy_value is extending borrow introducer "
203+
"lifetime, bailing out\n");
195204
return false;
196205
}
197206
}

0 commit comments

Comments
 (0)