Skip to content

Commit 52bd0c7

Browse files
committed
[SILGen] Add begin_borrow [var_decl] lifetimes.
1 parent 725a60b commit 52bd0c7

File tree

101 files changed

+662
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+662
-507
lines changed

lib/SILGen/SILGenDecl.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,9 @@ class LocalVariableInitialization : public SingleBufferInitialization {
566566
//
567567
// Only add a lexical lifetime to the box if the the variable it stores
568568
// requires one.
569-
if (lifetime.isLexical()) {
570-
Box = SGF.B.createBeginBorrow(decl, Box, /*isLexical=*/true);
571-
}
569+
Box = SGF.B.createBeginBorrow(
570+
decl, Box, /*isLexical=*/lifetime.isLexical(),
571+
/*hasPointerEscape=*/false, /*fromVarDecl=*/true);
572572
}
573573

574574
Addr = SGF.B.createProjectBox(decl, Box, 0);
@@ -835,16 +835,17 @@ class LetValueInitialization : public Initialization {
835835
// Otherwise, if we do not have a no implicit copy variable, just follow
836836
// the "normal path": perform a lexical borrow if the lifetime is lexical.
837837
if (!vd->isNoImplicitCopy()) {
838-
if (SGF.F.getLifetime(vd, value->getType()).isLexical())
839-
return SGF.B.createBeginBorrow(PrologueLoc, value, /*isLexical*/ true);
840-
else
841-
return value;
838+
return SGF.B.createBeginBorrow(
839+
PrologueLoc, value,
840+
/*isLexical=*/SGF.F.getLifetime(vd, value->getType()).isLexical(),
841+
/*hasPointerEscape=*/false, /*fromVarDecl=*/true);
842842
}
843843

844844
// If we have a no implicit copy lexical, emit the instruction stream so
845845
// that the move checker knows to check this variable.
846-
value = SGF.B.createBeginBorrow(PrologueLoc, value,
847-
/*isLexical*/ true);
846+
value = SGF.B.createBeginBorrow(
847+
PrologueLoc, value,
848+
/*isLexical*/ true, /*hasPointerEscape=*/false, /*fromVarDecl=*/true);
848849
value = SGF.B.createCopyValue(PrologueLoc, value);
849850
value = SGF.B.createOwnedCopyableToMoveOnlyWrapperValue(PrologueLoc, value);
850851
return SGF.B.createMarkUnresolvedNonCopyableValueInst(
@@ -2166,11 +2167,6 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
21662167
return;
21672168
}
21682169

2169-
if (!F.getLifetime(vd, Val->getType()).isLexical()) {
2170-
B.emitDestroyValueOperation(silLoc, Val);
2171-
return;
2172-
}
2173-
21742170
// This handles any case where we copy + begin_borrow or copyable_to_moveonly
21752171
// + begin_borrow. In either case we just need to end the lifetime of the
21762172
// begin_borrow's operand.

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,7 +3028,7 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
30283028
///
30293029
/// %box = alloc_box
30303030
/// %mark_uninit = mark_uninitialized %box
3031-
/// %lifetime = begin_borrow [lexical] %mark_uninit
3031+
/// %lifetime = begin_borrow [var_decl] %mark_uninit
30323032
/// %proj_box = project_box %lifetime
30333033
///
30343034
/// We are replacing a
@@ -3048,7 +3048,7 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
30483048
/// Consequently, it's not sufficient to just replace the destroy_value
30493049
/// %mark_uninit with a destroy_addr %proj_box (or to replace it with a diamond
30503050
/// where one branch has that destroy_addr) because the destroy_addr is a use
3051-
/// of %proj_box which must be within the lexical lifetime of the box.
3051+
/// of %proj_box which must be within the var_decl lifetime of the box.
30523052
///
30533053
/// On the other side, we are hemmed in by the fact that the end_borrow must
30543054
/// precede the dealloc_box which will be created in the diamond. So we
@@ -3084,12 +3084,12 @@ static bool adjustAllocBoxEndBorrow(SILInstruction *previous,
30843084
if (!pbi)
30853085
return false;
30863086

3087-
// This fixup only applies if we're destroying a project_box of the lexical
3087+
// This fixup only applies if we're destroying a project_box of the var_decl
30883088
// lifetime of an alloc_box.
30893089
auto *lifetime = dyn_cast<BeginBorrowInst>(pbi->getOperand());
30903090
if (!lifetime)
30913091
return false;
3092-
assert(lifetime->isLexical());
3092+
assert(lifetime->isFromVarDecl());
30933093
assert(isa<AllocBoxInst>(
30943094
cast<MarkUninitializedInst>(lifetime->getOperand())->getOperand()));
30953095

lib/SILOptimizer/Mandatory/ReferenceBindingTransform.cpp

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -173,35 +173,47 @@ CopyAddrInst *ReferenceBindingProcessor::findInit() {
173173
// Thus to find our initialization, we need to find a project_box use of our
174174
// target that directly initializes the value.
175175
CopyAddrInst *initInst = nullptr;
176-
for (auto *use : mark->getUses()) {
177-
LLVM_DEBUG(llvm::dbgs() << "Visiting use: " << *use->getUser());
178-
179-
if (auto *pbi = dyn_cast<ProjectBoxInst>(use->getUser())) {
180-
LLVM_DEBUG(llvm::dbgs() << " Found project_box! Visiting pbi uses!\n");
181-
182-
for (auto *pbiUse : pbi->getUses()) {
183-
LLVM_DEBUG(llvm::dbgs() << " Pbi Use: " << *pbiUse->getUser());
184-
auto *cai = dyn_cast<CopyAddrInst>(pbiUse->getUser());
185-
if (!cai || cai->getDest() != pbi) {
186-
LLVM_DEBUG(llvm::dbgs() << " Either not a copy_addr or dest is "
187-
"not the project_box! Skipping!\n");
188-
continue;
189-
}
190-
191-
if (initInst || !cai->isInitializationOfDest() || cai->isTakeOfSrc()) {
192-
LLVM_DEBUG(
193-
llvm::dbgs()
194-
<< " Either already found an init inst or is an assign of a "
195-
"dest or a take of src... emitting unknown pattern!\n");
196-
diagnosticEmitter.diagnoseUnknownPattern(mark);
197-
return nullptr;
198-
}
199-
assert(!initInst && "Init twice?!");
200-
assert(!cai->isTakeOfSrc());
201-
initInst = cai;
202-
LLVM_DEBUG(llvm::dbgs()
203-
<< " Found our init! Checking for other inits!\n");
176+
InstructionWorklist worklist(mark->getFunction());
177+
for (auto *user : mark->getUsers()) {
178+
worklist.push(user);
179+
}
180+
while (auto *user = worklist.pop()) {
181+
LLVM_DEBUG(llvm::dbgs() << "Visiting use: " << *user);
182+
183+
auto *bbi = dyn_cast<BeginBorrowInst>(user);
184+
if (bbi && bbi->isFromVarDecl()) {
185+
for (auto *user : bbi->getUsers()) {
186+
worklist.push(user);
187+
}
188+
continue;
189+
}
190+
auto *pbi = dyn_cast<ProjectBoxInst>(user);
191+
if (!pbi)
192+
continue;
193+
LLVM_DEBUG(llvm::dbgs() << " Found project_box! Visiting pbi uses!\n");
194+
195+
for (auto *pbiUse : pbi->getUses()) {
196+
LLVM_DEBUG(llvm::dbgs() << " Pbi Use: " << *pbiUse->getUser());
197+
auto *cai = dyn_cast<CopyAddrInst>(pbiUse->getUser());
198+
if (!cai || cai->getDest() != pbi) {
199+
LLVM_DEBUG(llvm::dbgs() << " Either not a copy_addr or dest is "
200+
"not the project_box! Skipping!\n");
201+
continue;
202+
}
203+
204+
if (initInst || !cai->isInitializationOfDest() || cai->isTakeOfSrc()) {
205+
LLVM_DEBUG(
206+
llvm::dbgs()
207+
<< " Either already found an init inst or is an assign of a "
208+
"dest or a take of src... emitting unknown pattern!\n");
209+
diagnosticEmitter.diagnoseUnknownPattern(mark);
210+
return nullptr;
204211
}
212+
assert(!initInst && "Init twice?!");
213+
assert(!cai->isTakeOfSrc());
214+
initInst = cai;
215+
LLVM_DEBUG(llvm::dbgs()
216+
<< " Found our init! Checking for other inits!\n");
205217
}
206218
}
207219
LLVM_DEBUG(llvm::dbgs() << "Final Init: " << *initInst);

test/AutoDiff/SILGen/autodiff_builtins.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func test_context_builtins_with_type<T>(t: T) {
9797
// CHECK-LABEL: sil{{.*}}@test_context_builtins_with_type : $@convention(thin) <T> (@in_guaranteed T) -> () {
9898
// CHECK: bb0({{%.*}} : $*T):
9999
// CHECK: [[CTX:%.*]] = builtin "autoDiffCreateLinearMapContextWithType"<T>({{%.*}} : $@thick T.Type) : $Builtin.NativeObject // users: {{.*}}
100-
// CHECK: [[BORROWED_CTX:%.*]] = begin_borrow [lexical] [[CTX]] : $Builtin.NativeObject // users: {{.*}}
100+
// CHECK: [[BORROWED_CTX:%.*]] = begin_borrow [lexical] [var_decl] [[CTX]] : $Builtin.NativeObject // users: {{.*}}
101101
// CHECK: [[BUF:%.*]] = builtin "autoDiffProjectTopLevelSubcontext"([[BORROWED_CTX]] : $Builtin.NativeObject) : $Builtin.RawPointer // users: {{.*}}
102102
// CHECK: [[BUF:%.*]] = builtin "autoDiffAllocateSubcontextWithType"<T>([[BORROWED_CTX]] : $Builtin.NativeObject, {{.*}} : $@thick T.Type) : $Builtin.RawPointer // users: {{.*}}
103103
// CHECK: destroy_value [[CTX]]

test/AutoDiff/SILOptimizer/activity_analysis.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,26 +350,26 @@ func testArrayUninitializedIntrinsicNested(_ x: Float, _ y: Float) -> [Float] {
350350
// CHECK: [ACTIVE] [[ARRAY:%.*]] = apply %14<Float>(%7) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
351351
// CHECK: [USEFUL] [[INT_LIT:%.*]] = integer_literal $Builtin.Word, 2
352352
// CHECK: [NONE] // function_ref _allocateUninitializedArray<A>(_:)
353-
// CHECK: [ACTIVE] [[TUP:%.*]] = apply %18<Float>([[INT_LIT]]) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
353+
// CHECK: [ACTIVE] [[TUP:%.*]] = apply %19<Float>([[INT_LIT]]) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
354354
// CHECK: [ACTIVE] (**[[LHS:%.*]]**, [[RHS:%.*]]) = destructure_tuple [[TUP]] : $(Array<Float>, Builtin.RawPointer)
355355
// CHECK: [VARIED] ([[LHS]], **[[RHS]]**) = destructure_tuple [[TUP]] : $(Array<Float>, Builtin.RawPointer)
356356
// CHECK: [ACTIVE] [[FLOAT_PTR:%.*]] = pointer_to_address [[RHS]] : $Builtin.RawPointer to [strict] $*Float
357357
// CHECK: [USEFUL] [[ZERO_LITERAL:%.*]] = integer_literal $Builtin.IntLiteral, 0
358358
// CHECK: [USEFUL] [[META:%.*]] = metatype $@thin Int.Type
359359
// CHECK: [NONE] // function_ref Int.init(_builtinIntegerLiteral:)
360-
// CHECK: [USEFUL] [[RESULT_2:%.*]] = apply %25([[ZERO_LITERAL]], [[META]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
360+
// CHECK: [USEFUL] [[RESULT_2:%.*]] = apply %26([[ZERO_LITERAL]], [[META]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
361361
// CHECK: [NONE] // function_ref Array.subscript.getter
362-
// CHECK: [NONE] %28 = apply %27<Float>([[FLOAT_PTR]], [[RESULT_2]], %15) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
362+
// CHECK: [NONE] %29 = apply %28<Float>([[FLOAT_PTR]], [[RESULT_2]], %16) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
363363
// CHECK: [VARIED] [[ONE_LITERAL:%.*]] = integer_literal $Builtin.Word, 1
364364
// CHECK: [ACTIVE] [[INDEX_ADDR:%.*]] = index_addr [[FLOAT_PTR]] : $*Float, [[ONE_LITERAL]] : $Builtin.Word
365365
// CHECK: [USEFUL] [[ONE_LITERAL_AGAIN:%.*]] = integer_literal $Builtin.IntLiteral, 1
366366
// CHECK: [USEFUL] [[META_AGAIN:%.*]] = metatype $@thin Int.Type
367367
// CHECK: [NONE] // function_ref Int.init(_builtinIntegerLiteral:)
368-
// CHECK: [USEFUL] %34 = apply %33([[ONE_LITERAL_AGAIN]], [[META_AGAIN]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
368+
// CHECK: [USEFUL] %35 = apply %34([[ONE_LITERAL_AGAIN]], [[META_AGAIN]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
369369
// CHECK: [NONE] // function_ref Array.subscript.getter
370-
// CHECK: [NONE] %36 = apply %35<Float>(%30, %34, %15) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
370+
// CHECK: [NONE] %37 = apply %36<Float>(%31, %35, %16) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
371371
// CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
372-
// CHECK: [ACTIVE] %38 = apply %37<Float>(%20) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
372+
// CHECK: [ACTIVE] %39 = apply %38<Float>([[LHS]]) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
373373

374374
// TF-978: Test array literal initialized with `apply` indirect results.
375375
struct Wrapper<T: Differentiable>: Differentiable {

test/SILGen/access_marker_gen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public struct S {
1212
// CHECK: bb0(%0 : @guaranteed $Optional<AnyObject>):
1313
// CHECK: [[BOX:%.*]] = alloc_box ${ var S }, var, name "s"
1414
// CHECK: [[MARKED_BOX:%.*]] = mark_uninitialized [var] [[BOX]] : ${ var S }
15-
// CHECK: [[BOX_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[MARKED_BOX]]
15+
// CHECK: [[BOX_LIFETIME:%[^,]+]] = begin_borrow [lexical] [var_decl] [[MARKED_BOX]]
1616
// CHECK: [[ADDR:%.*]] = project_box [[BOX_LIFETIME]] : ${ var S }, 0
1717
// CHECK: cond_br %{{.*}}, bb1, bb2
1818
// CHECK: bb1:
@@ -46,7 +46,7 @@ func takeS(_ s: S) {}
4646
// CHECK-LABEL: sil [ossa] @$s17access_marker_gen14modifyAndReadSyyF : $@convention(thin) () -> () {
4747
// CHECK: bb0:
4848
// CHECK: %[[BOX:.*]] = alloc_box ${ var S }, var, name "s"
49-
// CHECK: %[[BOX_LIFETIME:[^,]+]] = begin_borrow [lexical] %[[BOX]]
49+
// CHECK: %[[BOX_LIFETIME:[^,]+]] = begin_borrow [lexical] [var_decl] %[[BOX]]
5050
// CHECK: %[[ADDRS:.*]] = project_box %[[BOX_LIFETIME]] : ${ var S }, 0
5151
// CHECK: %[[ACCESS1:.*]] = begin_access [modify] [unknown] %[[ADDRS]] : $*S
5252
// CHECK: %[[ADDRI:.*]] = struct_element_addr %[[ACCESS1]] : $*S, #S.i

test/SILGen/address_only_types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func address_only_assignment_from_lv(_ dest: inout Unloadable, v: Unloadable) {
166166
var v = v
167167
// CHECK: bb0([[DEST:%[0-9]+]] : $*any Unloadable, [[VARG:%[0-9]+]] : $*any Unloadable):
168168
// CHECK: [[VBOX:%.*]] = alloc_box ${ var any Unloadable }
169-
// CHECK: [[V_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[VBOX]]
169+
// CHECK: [[V_LIFETIME:%[^,]+]] = begin_borrow [lexical] [var_decl] [[VBOX]]
170170
// CHECK: [[PBOX:%[0-9]+]] = project_box [[V_LIFETIME]]
171171
// CHECK: copy_addr [[VARG]] to [init] [[PBOX]] : $*any Unloadable
172172
dest = v
@@ -212,7 +212,7 @@ func address_only_var() -> Unloadable {
212212
// CHECK: bb0([[RET:%[0-9]+]] : $*any Unloadable):
213213
var x = some_address_only_function_1()
214214
// CHECK: [[XBOX:%[0-9]+]] = alloc_box ${ var any Unloadable }
215-
// CHECK: [[XBOX_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[XBOX]]
215+
// CHECK: [[XBOX_LIFETIME:%[^,]+]] = begin_borrow [lexical] [var_decl] [[XBOX]]
216216
// CHECK: [[XPB:%.*]] = project_box [[XBOX_LIFETIME]]
217217
// CHECK: apply {{%.*}}([[XPB]])
218218
return x

test/SILGen/async_conversion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ actor AnActor {
7070
// CHECK: hop_to_executor {{..*}} : $AnActor
7171
// [[F:%.*]] = function_ref @$s4test7AnActorC6calleryyYaFySicACYicfu_ : $@convention(thin) (@guaranteed AnActor) -> @owned @callee_guaranteed (Int) -> ()
7272
// [[APPLIED_F:%.*]] = apply [[F]]({{.*}}) : $@convention(thin) (@guaranteed AnActor) -> @owned @callee_guaranteed (Int) -> ()
73-
// [[BORROWED_F:%.*]] = begin_borrow [lexical] [[APPLIED_F]] : $@callee_guaranteed (Int) -> ()
73+
// [[BORROWED_F:%.*]] = begin_borrow [lexical] [var_decl] [[APPLIED_F]] : $@callee_guaranteed (Int) -> ()
7474
// [[COPIED_F:%.*]] = copy_value [[BORROWED_F]] : $@callee_guaranteed (Int) -> ()
7575
// [[THUNK:%.*]] = function_ref @$sSiIegy_SiIegHy_TR : $@convention(thin) @async (Int, @guaranteed @callee_guaranteed (Int) -> ()) -> ()
7676
// = partial_apply [callee_guaranteed] [[THUNK]]([[COPIED_F]]) : $@convention(thin) @async (Int, @guaranteed @callee_guaranteed (Int) -> ()) -> ()

test/SILGen/back_deployed_attr_struct_init.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public struct TopLevelStruct<T> {
1313
// CHECK: bb0([[SELF_OUT:%.*]] : $*TopLevelStruct<T>, [[T_ARG:%.*]] : $*T, [[METATYPE_ARG:%.*]] : $@thin TopLevelStruct<T>.Type):
1414
// CHECK: [[SELF:%.*]] = alloc_box $<τ_0_0> { var TopLevelStruct<τ_0_0> } <T>, var, name "self"
1515
// CHECK: [[MARKED_SELF:%.*]] = mark_uninitialized [rootself] [[SELF]] : $<τ_0_0> { var TopLevelStruct<τ_0_0> } <T>
16-
// CHECK: [[BORROWED_SELF:%.*]] = begin_borrow [lexical] [[MARKED_SELF]] : $<τ_0_0> { var TopLevelStruct<τ_0_0> } <T>
16+
// CHECK: [[BORROWED_SELF:%.*]] = begin_borrow [lexical] [var_decl] [[MARKED_SELF]] : $<τ_0_0> { var TopLevelStruct<τ_0_0> } <T>
1717
// CHECK: [[BOX:%.*]] = project_box [[BORROWED_SELF]] : $<τ_0_0> { var TopLevelStruct<τ_0_0> } <T>, 0
1818
// CHECK: [[T_STACK:%.*]] = alloc_stack $T
1919
// CHECK: copy_addr [[T_ARG]] to [init] [[T_STACK]] : $*T

test/SILGen/borrow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func useD(_ d: D) {}
1818
// CHECK-LABEL: sil hidden [ossa] @$s6borrow44lvalueBorrowShouldBeAtEndOfFormalAccessScope{{.*}} : $@convention(thin) () -> () {
1919
// CHECK: bb0:
2020
// CHECK: [[BOX:%.*]] = alloc_box ${ var C }, var, name "c"
21-
// CHECK: [[BOX_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[BOX]]
21+
// CHECK: [[BOX_LIFETIME:%[^,]+]] = begin_borrow [lexical] [var_decl] [[BOX]]
2222
// CHECK: [[PB_BOX:%.*]] = project_box [[BOX_LIFETIME]]
2323
// CHECK: [[ACCESS:%.*]] = begin_access [read] [unknown] [[PB_BOX]] : $*C
2424
// CHECK: [[CLASS:%.*]] = load [copy] [[ACCESS]]

test/SILGen/boxed_existentials.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func test_property_of_lvalue(_ x: Error) -> String {
8282
// CHECK-LABEL: sil hidden [ossa] @$s18boxed_existentials23test_property_of_lvalueySSs5Error_pF :
8383
// CHECK: bb0([[ARG:%.*]] : @guaranteed $any Error):
8484
// CHECK: [[VAR:%.*]] = alloc_box ${ var any Error }
85-
// CHECK: [[VAR_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[VAR]]
85+
// CHECK: [[VAR_LIFETIME:%[^,]+]] = begin_borrow [lexical] [var_decl] [[VAR]]
8686
// CHECK: [[PVAR:%.*]] = project_box [[VAR_LIFETIME]]
8787
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]] : $any Error
8888
// CHECK: store [[ARG_COPY]] to [init] [[PVAR]]
@@ -133,10 +133,10 @@ func test_open_existential_semantics(_ guaranteed: Error,
133133
_ immediate: Error) {
134134
var immediate = immediate
135135
// CHECK: [[IMMEDIATE_BOX:%.*]] = alloc_box ${ var any Error }
136-
// CHECK: [[IMMEDIATE_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[IMMEDIATE_BOX]]
136+
// CHECK: [[IMMEDIATE_LIFETIME:%[^,]+]] = begin_borrow [lexical] [var_decl] [[IMMEDIATE_BOX]]
137137
// CHECK: [[PB:%.*]] = project_box [[IMMEDIATE_LIFETIME]]
138138
// GUARANTEED: [[IMMEDIATE_BOX:%.*]] = alloc_box ${ var any Error }
139-
// GUARANTEED: [[IMMEDIATE_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[IMMEDIATE_BOX]]
139+
// GUARANTEED: [[IMMEDIATE_LIFETIME:%[^,]+]] = begin_borrow [lexical] [var_decl] [[IMMEDIATE_BOX]]
140140
// GUARANTEED: [[PB:%.*]] = project_box [[IMMEDIATE_LIFETIME]]
141141

142142
// CHECK-NOT: copy_value [[ARG0]]
@@ -204,7 +204,7 @@ func test_open_existential_semantics(_ guaranteed: Error,
204204
func erasure_to_any(_ guaranteed: Error, _ immediate: Error) -> Any {
205205
var immediate = immediate
206206
// CHECK: [[IMMEDIATE_BOX:%.*]] = alloc_box ${ var any Error }
207-
// CHECK: [[IMMEDIATE_LIFETIME:%[^,]+]] = begin_borrow [lexical] [[IMMEDIATE_BOX]]
207+
// CHECK: [[IMMEDIATE_LIFETIME:%[^,]+]] = begin_borrow [lexical] [var_decl] [[IMMEDIATE_BOX]]
208208
// CHECK: [[PB:%.*]] = project_box [[IMMEDIATE_LIFETIME]]
209209
if true {
210210
// CHECK-NOT: copy_value [[GUAR]]

test/SILGen/cf_members.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public func foo(_ x: Double) {
6868
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
6969
// CHECK: [[THUNK:%.*]] = function_ref @$s10cf_members3fooyySdFSo10IAMStruct1VSdcADcfu0_ : $@convention(thin) (Struct1) -> @owned @callee_guaranteed (Double) -> Struct1
7070
// CHECK: [[C:%.*]] = apply [[THUNK]]([[ZVAL]])
71-
// CHECK: [[BORROWED_C:%.*]] = begin_borrow [lexical] [[C]]
71+
// CHECK: [[BORROWED_C:%.*]] = begin_borrow [lexical] [var_decl] [[C]]
7272
// CHECK: [[C_COPY:%.*]] = copy_value [[BORROWED_C]]
7373
// CHECK: [[BORROWED_C2:%.*]] = begin_borrow [[C_COPY]]
7474
let c: (Double) -> Struct1 = z.translate(radians:)
@@ -102,7 +102,7 @@ public func foo(_ x: Double) {
102102
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
103103
// CHECK: [[THUNK:%.*]] = function_ref @$s10cf_members3fooyySdFSo10IAMStruct1VSdcADcfu4_ : $@convention(thin) (Struct1) -> @owned @callee_guaranteed (Double) -> Struct1
104104
// CHECK: [[F:%.*]] = apply [[THUNK]]([[ZVAL]])
105-
// CHECK: [[BORROWED_F:%.*]] = begin_borrow [lexical] [[F]]
105+
// CHECK: [[BORROWED_F:%.*]] = begin_borrow [lexical] [var_decl] [[F]]
106106
// CHECK: [[F_COPY:%.*]] = copy_value [[BORROWED_F]]
107107
// CHECK: [[BORROWED_F2:%.*]] = begin_borrow [[F_COPY]]
108108
let f = z.scale

0 commit comments

Comments
 (0)