Skip to content

Commit de3dd2a

Browse files
committed
---
yaml --- r: 347162 b: refs/heads/master c: e1ea272 h: refs/heads/master
1 parent 5825eaf commit de3dd2a

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8574ae53a1c993393e46a0f92cd821c31d1e5083
2+
refs/heads/master: e1ea272cf30ad8dda92fed0a4f7a6eb23cc519ba
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/SILGen/SILGenPoly.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ static ManagedValue emitTransformExistential(SILGenFunction &SGF,
241241
[&](SGFContext C) -> ManagedValue {
242242
if (openedArchetype)
243243
return SGF.manageOpaqueValue(state, loc, C);
244-
return input;
244+
if (input.isPlusOne(SGF))
245+
return input;
246+
if (C.isGuaranteedPlusZeroOk())
247+
return input;
248+
return input.copyUnmanaged(SGF, loc);
245249
});
246250

247251
return input;

trunk/test/IRGen/outlined_copy_addr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-ir -module-name outcopyaddr -primary-file %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-ir -enable-sil-ownership -module-name outcopyaddr -primary-file %s | %FileCheck %s
22

33
public protocol BaseProt {
44
}

trunk/test/SILGen/reabstract.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,23 @@ func testSharedOwnedOpaque(_ s: C, o: C) {
112112
let box = Box(t: evenLessFun)
113113
box.t(s, o)
114114
}
115+
116+
// Make sure that when we generate the reabstraction thunk from Klass -> P, we
117+
// pass off the value at +1.
118+
// CHECK-LABEL: sil shared [transparent] [serializable] [reabstraction_thunk] [ossa] @$s10reabstract1P_pIegg_xIegg_AaBRzlTR : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@guaranteed τ_0_0, @guaranteed @callee_guaranteed (@guaranteed P) -> ()) -> () {
119+
// CHECK: bb0([[ARG:%.*]] : @guaranteed $τ_0_0,
120+
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
121+
// CHECK: [[EXISTENTIAL:%.*]] = init_existential_ref [[ARG_COPY]]
122+
// CHECK: [[BORROWED_EXISTENTIAL:%.*]] = begin_borrow [[EXISTENTIAL]]
123+
// CHECK: apply {{%.*}}([[BORROWED_EXISTENTIAL]])
124+
// CHECK: end_borrow [[BORROWED_EXISTENTIAL]]
125+
// CHECK: destroy_value [[EXISTENTIAL]]
126+
// CHECK: } // end sil function '$s10reabstract1P_pIegg_xIegg_AaBRzlTR'
127+
protocol P : class {}
128+
class Klass : P { }
129+
extension P { static func crash(setup: ((Self) -> ())?) {} }
130+
func checkInitExistentialThunk() -> P? {
131+
let cls : P.Type = Klass.self
132+
cls.crash(setup: { (arg: P) -> () in })
133+
return nil
134+
}

0 commit comments

Comments
 (0)