Skip to content

Commit 97d17a5

Browse files
committed
Fix a crash in the mandatory inliner related to optimization remarks
Even if a function's type has a self parameter, it may be specialized and the function argument is actually not there anymore. rdar://103065348
1 parent e80e7e3 commit 97d17a5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: lib/SIL/Utils/OptimizationRemark.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static bool hasForceEmitSemanticAttr(SILFunction &fn, StringRef passName) {
136136
}
137137

138138
static bool isMethodWithForceEmitSemanticAttrNominalType(SILFunction &fn) {
139-
if (!fn.hasSelfParam())
139+
if (!fn.hasSelfParam() || fn.getArguments().empty())
140140
return false;
141141

142142
auto selfType = fn.getSelfArgument()->getType();

Diff for: test/SILOptimizer/performance-annotations.swift

+5
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,8 @@ func closueWhichModifiesLocalVar() -> Int {
223223
return x
224224
}
225225

226+
@_noAllocation
227+
func createEmptyArray() {
228+
_ = [Int]() // expected-error {{ending the lifetime of a value of type}}
229+
}
230+

0 commit comments

Comments
 (0)