Skip to content

Commit 49fe60c

Browse files
committed
[ownership-verifier] Instead of dumping the entire block, just dump the block's debug id.
Thanks to Erik for pointing out to me that this is the same value as a block's printed ID. This makes the output significantly more readable!
1 parent 6205344 commit 49fe60c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,8 @@ bool SILValueOwnershipChecker::doesBlockContainUseAfterFree(
666666
<< "Function: '" << Value->getFunction()->getName() << "'\n"
667667
<< "Value: " << *Value
668668
<< "Consuming User: " << *LifetimeEndingUser
669-
<< "Non Consuming User: " << *Iter->second << "Block:\n"
670-
<< *UserBlock << "\n";
669+
<< "Non Consuming User: " << *Iter->second << "Block: bb"
670+
<< UserBlock->getDebugID() << "\n";
671671
return true;
672672
}
673673

@@ -688,7 +688,7 @@ bool SILValueOwnershipChecker::doesBlockDoubleConsume(
688688
<< "Value: " << *Value;
689689
if (LifetimeEndingUser)
690690
llvm::errs() << "User: " << *LifetimeEndingUser;
691-
llvm::errs() << "Block:\n" << *UserBlock << "\n";
691+
llvm::errs() << "Block: bb" << UserBlock->getDebugID() << "\n\n";
692692

693693
return true;
694694
}
@@ -758,7 +758,8 @@ static bool checkFunctionArgWithoutLifetimeEndingUses(SILFunctionArgument *Arg,
758758

759759
llvm::errs() << " Owned function parameter without life "
760760
"ending uses!\n"
761-
<< "Value: " << *Arg;
761+
<< "Function: '" << Arg->getFunction()->getName() << "'\n"
762+
<< "Value: " << *Arg << '\n';
762763
if (PrintMessageInsteadOfAssert)
763764
return true;
764765
llvm_unreachable("triggering standard assertion failure routine");
@@ -776,7 +777,8 @@ bool SILValueOwnershipChecker::checkValueWithoutLifetimeEndingUses() {
776777
llvm::errs() << "Non trivial values, non address values, and non "
777778
"guaranteed function args must have at least one "
778779
"lifetime ending use?!\n"
779-
<< "Value: " << *Value;
780+
<< "Function: '" << Value->getFunction()->getName() << "'\n"
781+
<< "Value: " << *Value << '\n';
780782
if (PrintMessageInsteadOfAssert)
781783
return true;
782784
llvm_unreachable("triggering standard assertion failure routine");
@@ -792,10 +794,12 @@ static bool isGuaranteedFunctionArgWithLifetimeEndingUses(
792794
return true;
793795

794796
llvm::errs() << " Guaranteed function parameter with life ending uses!\n"
795-
<< "Value: " << *Arg;
797+
<< " Function: '" << Arg->getFunction()->getName() << "'\n"
798+
<< " Value: " << *Arg;
796799
for (auto *U : LifetimeEndingUsers) {
797800
llvm::errs() << " Lifetime Ending User: " << *U;
798801
}
802+
llvm::errs() << '\n';
799803
if (PrintMessageInsteadOfAssert)
800804
return false;
801805
llvm_unreachable("triggering standard assertion failure routine");
@@ -922,7 +926,7 @@ void SILValueOwnershipChecker::checkDataflow() {
922926
while (!Worklist.empty()) {
923927
// Grab the next block to visit.
924928
SILBasicBlock *BB = Worklist.pop_back_val();
925-
DEBUG(llvm::dbgs() << " Visiting Block:\n" << *BB);
929+
DEBUG(llvm::dbgs() << " Visiting Block: bb" << BB->getDebugID() << '\n');
926930

927931
// Since the block is on our worklist, we know already that it is not a
928932
// block with lifetime ending uses, due to the invariants of our loop.
@@ -982,8 +986,9 @@ void SILValueOwnershipChecker::checkDataflow() {
982986
<< "Function: '" << Value->getFunction()->getName() << "'\n"
983987
<< " Value: " << *Value << " Post Dominating Failure Blocks:\n";
984988
for (auto *BB : SuccessorBlocksThatMustBeVisited) {
985-
llvm::errs() << *BB;
989+
llvm::errs() << "bb" << BB->getDebugID();
986990
}
991+
llvm::errs() << '\n';
987992
if (PrintMessageInsteadOfAssert)
988993
return;
989994
llvm_unreachable("triggering standard assertion failure routine");
@@ -998,8 +1003,8 @@ void SILValueOwnershipChecker::checkDataflow() {
9981003
<< "Function: '" << Value->getFunction()->getName() << "'\n"
9991004
<< "Value: " << *Value << " Remaining Users:\n";
10001005
for (auto &Pair : BlocksWithNonLifetimeEndingUses) {
1001-
llvm::errs() << "User:" << *Pair.second << "Block:\n"
1002-
<< *Pair.first << "\n";
1006+
llvm::errs() << "User:" << *Pair.second << "Block: bb"
1007+
<< Pair.first->getDebugID() << "\n\n";
10031008
}
10041009
if (PrintMessageInsteadOfAssert)
10051010
return;

test/SIL/ownership-verifier/over_consume.sil

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import Builtin
1111
// CHECK: Found over consume?!
1212
// CHECK: Value: %0 = argument of bb0 : $Builtin.NativeObject
1313
// CHECK: User: destroy_value %0 : $Builtin.NativeObject
14-
// CHECK: Block
15-
// CHECK: bb0(
14+
// CHECK: Block: bb0
1615
sil @double_consume_same_bb : $@convention(thin) (@owned Builtin.NativeObject) -> () {
1716
bb0(%0 : $Builtin.NativeObject):
1817
destroy_value %0 : $Builtin.NativeObject
@@ -27,8 +26,7 @@ bb0(%0 : $Builtin.NativeObject):
2726
// CHECK: Found over consume?!
2827
// CHECK: Value: %0 = argument of bb0 : $Builtin.NativeObject
2928
// CHECK: User: destroy_value %0 : $Builtin.NativeObject
30-
// CHECK: Block:
31-
// CHECK: bb0(
29+
// CHECK: Block: bb0
3230
sil @double_consume_jump_thread_blocks : $@convention(thin) (@owned Builtin.NativeObject) -> () {
3331
bb0(%0 : $Builtin.NativeObject):
3432
destroy_value %0 : $Builtin.NativeObject
@@ -45,8 +43,7 @@ bb1:
4543
// CHECK-LABEL: Function: 'double_consume_loop_test'
4644
// CHECK: Found over consume?!
4745
// CHECK: Value: %0 = argument of bb0 : $Builtin.NativeObject
48-
// CHECK: Block:
49-
// CHECK: bb0(
46+
// CHECK: Block: bb0
5047
sil @double_consume_loop_test : $@convention(thin) (@owned Builtin.NativeObject) -> () {
5148
bb0(%0 : $Builtin.NativeObject):
5249
%1 = alloc_stack $Builtin.NativeObject

0 commit comments

Comments
 (0)