@@ -131,46 +131,45 @@ void AccessSummaryAnalysis::processArgument(FunctionInfo *info,
131
131
// / only ultimately used by an apply, a try_apply or as an argument (but not
132
132
// / the called function) in a partial_apply.
133
133
// / TODO: This really should be checked in the SILVerifier.
134
- static bool hasExpectedUsesOfNoEscapePartialApply (SILInstruction *closure) {
135
- for (Operand *use : closure->getUses ()) {
136
- SILInstruction *user = use->getUser ();
134
+ static bool hasExpectedUsesOfNoEscapePartialApply (Operand *partialApplyUse) {
135
+ SILInstruction *user = partialApplyUse->getUser ();
137
136
138
- // It is fine to call the partial apply
139
- switch (user->getKind ()) {
140
- case ValueKind::ApplyInst:
141
- case ValueKind::TryApplyInst:
142
- return true ;
143
-
144
- case ValueKind::ConvertFunctionInst:
145
- return hasExpectedUsesOfNoEscapePartialApply (user);
137
+ // It is fine to call the partial apply
138
+ switch (user->getKind ()) {
139
+ case ValueKind::ApplyInst:
140
+ case ValueKind::TryApplyInst:
141
+ return true ;
146
142
147
- case ValueKind::PartialApplyInst:
148
- return closure != cast<PartialApplyInst>(user)->getCallee ();
149
-
150
- case ValueKind::StoreInst:
151
- case ValueKind::DestroyValueInst:
152
- // @block_storage is passed by storing it to the stack. We know this is
153
- // still nonescaping simply because our original argument convention is
154
- // @inout_aliasable. In this SIL, both store and destroy_value are users
155
- // of %closure:
156
- //
157
- // %closure = partial_apply %f1(%arg)
158
- // : $@convention(thin) (@inout_aliasable T) -> ()
159
- // %storage = alloc_stack $@block_storage @callee_owned () -> ()
160
- // %block_addr = project_block_storage %storage
161
- // : $*@block_storage @callee_owned () -> ()
162
- // store %closure to [init] %block_addr : $*@callee_owned () -> ()
163
- // %block = init_block_storage_header %storage
164
- // : $*@block_storage @callee_owned () -> (),
165
- // invoke %f2 : $@convention(c)
166
- // (@inout_aliasable @block_storage @callee_owned () -> ()) -> (),
167
- // type $@convention(block) () -> ()
168
- // %copy = copy_block %block : $@convention(block) () -> ()
169
- // destroy_value %storage : $@callee_owned () -> ()
170
- return true ;
171
- default :
172
- return false ;
173
- }
143
+ case ValueKind::ConvertFunctionInst:
144
+ return llvm::all_of (user->getUses (),
145
+ hasExpectedUsesOfNoEscapePartialApply);
146
+
147
+ case ValueKind::PartialApplyInst:
148
+ return partialApplyUse->get () != cast<PartialApplyInst>(user)->getCallee ();
149
+
150
+ case ValueKind::StoreInst:
151
+ case ValueKind::DestroyValueInst:
152
+ // @block_storage is passed by storing it to the stack. We know this is
153
+ // still nonescaping simply because our original argument convention is
154
+ // @inout_aliasable. In this SIL, both store and destroy_value are users
155
+ // of %closure:
156
+ //
157
+ // %closure = partial_apply %f1(%arg)
158
+ // : $@convention(thin) (@inout_aliasable T) -> ()
159
+ // %storage = alloc_stack $@block_storage @callee_owned () -> ()
160
+ // %block_addr = project_block_storage %storage
161
+ // : $*@block_storage @callee_owned () -> ()
162
+ // store %closure to [init] %block_addr : $*@callee_owned () -> ()
163
+ // %block = init_block_storage_header %storage
164
+ // : $*@block_storage @callee_owned () -> (),
165
+ // invoke %f2 : $@convention(c)
166
+ // (@inout_aliasable @block_storage @callee_owned () -> ()) -> (),
167
+ // type $@convention(block) () -> ()
168
+ // %copy = copy_block %block : $@convention(block) () -> ()
169
+ // destroy_value %storage : $@callee_owned () -> ()
170
+ return true ;
171
+ default :
172
+ return false ;
174
173
}
175
174
}
176
175
#endif
@@ -189,8 +188,9 @@ void AccessSummaryAnalysis::processPartialApply(FunctionInfo *callerInfo,
189
188
assert (isa<FunctionRefInst>(apply->getCallee ()) &&
190
189
" Noescape partial apply of non-functionref?" );
191
190
192
- assert (hasExpectedUsesOfNoEscapePartialApply (apply)
193
- && " noescape partial_apply has unexpected use!" );
191
+ assert (llvm::all_of (apply->getUses (),
192
+ hasExpectedUsesOfNoEscapePartialApply) &&
193
+ " noescape partial_apply has unexpected use!" );
194
194
195
195
// The argument index in the called function.
196
196
ApplySite site (apply);
0 commit comments