Skip to content

Commit 0a6c712

Browse files
committed
[OSSACompleteLifetime] Flag disables leak checking
The utility effectively determines whether a value leaks as part of its work, a subset of the checking done by the ownership verifier. Disable that checking when the flag that disables the ownership verifier is passed.
1 parent c197ca1 commit 0a6c712

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

lib/SIL/Utils/OSSALifetimeCompletion.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,11 @@ void AvailabilityBoundaryVisitor::computeRegion(
333333
// Thus finding a value available at the end of such a block means that
334334
// the block does _not_ must not exits the function normally; in other
335335
// words its terminator must be an UnreachableInst.
336-
if (!isa<UnreachableInst>(block->getTerminator())) {
336+
if (!isa<UnreachableInst>(block->getTerminator()) &&
337+
block->getFunction()
338+
->getModule()
339+
.getASTContext()
340+
.SILOpts.VerifySILOwnership) {
337341
llvm::errs() << "Invalid SIL provided to OSSALifetimeCompletion?! {{\n";
338342
llvm::errs() << "OSSALifetimeCompletion is visiting the availability "
339343
"boundary of ";
@@ -358,6 +362,8 @@ void AvailabilityBoundaryVisitor::computeRegion(
358362
<< "-sil-ownership-verify-all -Xllvm '-sil-print-function="
359363
<< block->getFunction()->getName()
360364
<< "' -Xllvm -sil-print-types -Xllvm -sil-print-module-on-error\n";
365+
llvm::errs() << "Use the -disable-sil-ownership-verifier to disable "
366+
"this check.\n";
361367
llvm::report_fatal_error("Invalid lifetime of value whose availability "
362368
"boundary is being visited.");
363369
}
@@ -430,7 +436,11 @@ void AvailabilityBoundaryVisitor::visitAvailabilityBoundary(
430436
continue;
431437
}
432438
assert(hasUnavailableSuccessor() ||
433-
isa<UnreachableInst>(block->getTerminator()));
439+
isa<UnreachableInst>(block->getTerminator()) ||
440+
!block->getFunction()
441+
->getModule()
442+
.getASTContext()
443+
.SILOpts.VerifySILOwnership);
434444
visit(block->getTerminator(),
435445
OSSALifetimeCompletion::LifetimeEnd::Boundary);
436446
}

validation-test/SILOptimizer/ossa_lifetime_completion_crash.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class C {}
2424
// CHECK: Something that ran before OSSALifetimeCompletion (the current pass, an earlier pass, SILGen) has introduced a leak of this value.
2525
// CHECK: Please rerun the crashing swift-frontend command with the following flags added and file a bug with the output:
2626
// CHECK: -sil-ownership-verify-all -Xllvm '-sil-print-function=leak_c' -Xllvm -sil-print-types -Xllvm -sil-print-module-on-error
27+
// CHECK: Use the -disable-sil-ownership-verifier to disable this check.
2728
// CHECK: Invalid lifetime of value whose availability boundary is being visited.
2829
sil [ossa] @leak_c : $@convention(thin) (@owned C) -> () {
2930
entry(%c : @owned $C):
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-sil-opt -sil-print-types \
2+
// RUN: -test-runner \
3+
// RUN: %s \
4+
// RUN: -sil-disable-input-verify \
5+
// RUN: -disable-sil-ownership-verifier \
6+
// RUN: -o /dev/null \
7+
// RUN: 2>&1 | %FileCheck %s
8+
9+
class C {}
10+
11+
// CHECK: end running test
12+
sil [ossa] @leak_c : $@convention(thin) (@owned C) -> () {
13+
entry(%c : @owned $C):
14+
specify_test "ossa_lifetime_completion @argument availability"
15+
return undef : $()
16+
}

0 commit comments

Comments
 (0)