Skip to content

Commit ac020e0

Browse files
author
Joe Shajrawi
authored
Merge pull request #14194 from apple/load_part_apply_cherry
Merge pull request #14187 from shajrawi/fix_part_apply
2 parents 3e6b75a + 8a3e25d commit ac020e0

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,16 @@ static bool shouldTransformFunctionType(GenericEnvironment *env,
8080
CanSILFunctionType fnType,
8181
irgen::IRGenModule &IGM);
8282

83+
static SILParameterInfo getNewParameter(GenericEnvironment *env,
84+
SILParameterInfo param,
85+
irgen::IRGenModule &IGM);
86+
8387
static bool shouldTransformParameter(GenericEnvironment *env,
8488
SILParameterInfo param,
8589
irgen::IRGenModule &IGM) {
86-
SILType storageType = param.getSILStorageType();
87-
88-
// FIXME: only function types and not recursively-transformable types?
89-
if (auto fnType = storageType.getAs<SILFunctionType>())
90-
return shouldTransformFunctionType(env, fnType, IGM);
9190

92-
switch (param.getConvention()) {
93-
case ParameterConvention::Indirect_In_Guaranteed:
94-
case ParameterConvention::Indirect_Inout:
95-
case ParameterConvention::Indirect_InoutAliasable:
96-
case ParameterConvention::Indirect_In:
97-
return false;
98-
default:
99-
return isLargeLoadableType(env, storageType, IGM);
100-
}
91+
auto newParam = getNewParameter(env, param, IGM);
92+
return (param != newParam);
10193
}
10294

10395
static bool shouldTransformFunctionType(GenericEnvironment *env,
@@ -2604,6 +2596,10 @@ void LoadableByAddress::run() {
26042596
if (isa<ProjectBlockStorageInst>(dest)) {
26052597
storeToBlockStorageInstrs.insert(SI);
26062598
}
2599+
} else if (auto *PAI = dyn_cast<PartialApplyInst>(&I)) {
2600+
if (modApplies.count(PAI) == 0) {
2601+
modApplies.insert(PAI);
2602+
}
26072603
}
26082604
}
26092605
}

test/IRGen/big_types_corner_cases.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -enable-large-loadable-types %s -emit-ir | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
2+
// REQUIRES: optimized_stdlib
23
// UNSUPPORTED: resilient_stdlib
34

45
public struct BigStruct {
@@ -205,3 +206,17 @@ func bigStructGet() -> BigStruct {
205206
public func testGetFunc() {
206207
let testGetPtr: @convention(thin) () -> BigStruct = bigStructGet
207208
}
209+
210+
// CHECK-LABEL: define{{( protected)?}} hidden swiftcc void @_T022big_types_corner_cases7TestBigC4testyyF(%T22big_types_corner_cases7TestBigC* swiftself)
211+
// CHECK: [[CALL1:%.*]] = call %swift.type* @_T0Sayy22big_types_corner_cases9BigStructVcSgGMa
212+
// CHECK: [[CALL2:%.*]] = call i8** @_T0Sayy22big_types_corner_cases9BigStructVcSgGSayxGs10CollectionsWl
213+
// CHECK: call swiftcc void @_T0s10CollectionPsE5index5IndexQzSgSb7ElementQzKc5where_tKF(%TSq.0* noalias nocapture sret %10, i8* bitcast (i1 (%T22big_types_corner_cases9BigStructVytIegir_Sg*, %swift.refcounted*, %swift.error**)* @_T022big_types_corner_cases9BigStructVIegy_SgSbs5Error_pIgxdzo_ACytIegir_SgSbsAE_pIgidzo_TRTA to i8*), %swift.refcounted* %7, %swift.type* %11, i8** [[CALL2]]
214+
// CHECK: ret void
215+
class TestBig {
216+
typealias Handler = (BigStruct) -> Void
217+
218+
func test() {
219+
let arr = [Handler?]()
220+
let d = arr.index(where: { _ in true })
221+
}
222+
}

0 commit comments

Comments
 (0)