Skip to content

Commit 158a3ed

Browse files
committed
LoadableByAddress: Fix code that changes lowered return type of function.
It confused the original type's substituted generic signature for the new type's invocation generic signature, leading to corrupted SIL when a function had a substituted SIL function type with a return type involving large loadable types that have to be passed indirectly in IR. Fixes rdar://87792152
1 parent 46c2e8d commit 158a3ed

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ static bool rewriteFunctionReturn(StructLoweringState &pass) {
23622362
}
23632363

23642364
auto NewTy = SILFunctionType::get(
2365-
loweredTy->getSubstGenericSignature(),
2365+
loweredTy->getInvocationGenericSignature(),
23662366
loweredTy->getExtInfo(),
23672367
loweredTy->getCoroutineKind(),
23682368
loweredTy->getCalleeConvention(),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// rdar://87792152
2+
// RUN: %target-swift-frontend -disable-availability-checking -emit-ir -verify %s
3+
4+
public struct S1 {
5+
var a: Int?
6+
var b: Int?
7+
var c: Int?
8+
}
9+
10+
public struct S2 {
11+
public func foo() {
12+
_ = bar
13+
}
14+
15+
func bar(_: S1) -> some Any {
16+
return 0
17+
}
18+
}

0 commit comments

Comments
 (0)