Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/SILOptimizer/Mandatory/PerformanceDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ bool PerformanceDiagnostics::visitFunction(SILFunction *function,
if (auto *fri = dyn_cast<FunctionRefInst>(bi->getArguments()[1])) {
if (visitCallee(bi, fri->getReferencedFunction(), perfConstr, parentLoc))
return true;
} else {
} else if (perfConstr != PerformanceConstraints::ManualOwnership) {
LocWithParent loc(inst.getLoc().getSourceLoc(), parentLoc);
diagnose(loc, diag::performance_unknown_callees);
return true;
Expand Down Expand Up @@ -250,6 +250,12 @@ bool PerformanceDiagnostics::checkClosureValue(SILValue closure,
SILInstruction *callInst,
PerformanceConstraints perfConstr,
LocWithParent *parentLoc) {
// Closures within a function are pre-annotated with [manual_ownership]
// within SILGen, if they're visible to users for annotation at all.
// So no recursive closure checking is needed here.
if (perfConstr == PerformanceConstraints::ManualOwnership)
return false;

// Walk through the definition of the closure until we find the "underlying"
// function_ref instruction.
while (!isa<FunctionRefInst>(closure)) {
Expand Down
8 changes: 8 additions & 0 deletions test/SIL/manual_ownership.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ func basic_methods_consuming_fixed(_ t1: Triangle) {
(copy t2).consuming() // FIXME: why is this not propagated?
}

open class OpenClass {
open func classMethod() {}
}
@_manualOwnership
func callOpenMethod(_ c: OpenClass) {
return c.classMethod()
}

@_manualOwnership
@discardableResult
func consumingFunc(_ t0: consuming Triangle) -> Bool { return false }
Expand Down