Skip to content

Commit a4bd03c

Browse files
authored
Merge pull request #76464 from kubamracek/embedded-fix-generics-check-in-perfdiags
[embedded] Fix generic function skipping in PerfDiags, diagnose KeyPathInsts in closures
2 parents 09b5431 + e7b7405 commit a4bd03c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/SILOptimizer/Mandatory/PerformanceDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ bool PerformanceDiagnostics::visitFunctionEmbeddedSwift(
203203
SILFunction *function, LocWithParent *parentLoc) {
204204
// Don't check generic functions in embedded Swift, they're about to be
205205
// removed anyway.
206-
if (function->getLoweredFunctionType()->getSubstGenericSignature())
206+
if (function->isGeneric())
207207
return false;
208208

209209
if (!function->isDefinition())

test/embedded/keypaths4.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-emit-ir -verify %s -enable-experimental-feature Embedded -wmo
2+
3+
// REQUIRES: swift_in_compiler
4+
// REQUIRES: optimized_stdlib
5+
// REQUIRES: OS=macosx || OS=linux-gnu
6+
7+
public func foo() {
8+
let number = 42
9+
_ = withUnsafeBytes(of: number) { bytes in
10+
bytes.map(\.description).joined(separator: ".") // expected-error {{cannot use key path in embedded Swift}}
11+
}
12+
}

0 commit comments

Comments
 (0)