@@ -281,6 +281,19 @@ void MemoryLocations::clear() {
281
281
nonTrivialLocations.clear ();
282
282
}
283
283
284
+ static bool hasInoutArgument (ApplySite AS) {
285
+ for (Operand &op : AS.getArgumentOperands ()) {
286
+ switch (AS.getArgumentConvention (op)) {
287
+ case SILArgumentConvention::Indirect_Inout:
288
+ case SILArgumentConvention::Indirect_InoutAliasable:
289
+ return true ;
290
+ default :
291
+ break ;
292
+ }
293
+ }
294
+ return false ;
295
+ }
296
+
284
297
bool MemoryLocations::analyzeLocationUsesRecursively (SILValue V, unsigned locIdx,
285
298
SmallVectorImpl<SILValue> &collectedVals,
286
299
SubLocationMap &subLocationMap) {
@@ -329,6 +342,13 @@ bool MemoryLocations::analyzeLocationUsesRecursively(SILValue V, unsigned locIdx
329
342
/* fieldNr*/ 0 , collectedVals, subLocationMap))
330
343
return false ;
331
344
break ;
345
+ case SILInstructionKind::PartialApplyInst:
346
+ // inout/inout_aliasable conventions means that the argument "escapes".
347
+ // This is okay for memory verification, but cannot handled by other
348
+ // optimizations, like DestroyHoisting.
349
+ if (!handleNonTrivialProjections && hasInoutArgument (ApplySite (user)))
350
+ return false ;
351
+ break ;
332
352
case SILInstructionKind::InjectEnumAddrInst:
333
353
case SILInstructionKind::SelectEnumAddrInst:
334
354
case SILInstructionKind::ExistentialMetatypeInst:
@@ -344,7 +364,6 @@ bool MemoryLocations::analyzeLocationUsesRecursively(SILValue V, unsigned locIdx
344
364
case SILInstructionKind::CheckedCastAddrBranchInst:
345
365
case SILInstructionKind::UncheckedRefCastAddrInst:
346
366
case SILInstructionKind::UnconditionalCheckedCastAddrInst:
347
- case SILInstructionKind::PartialApplyInst:
348
367
case SILInstructionKind::ApplyInst:
349
368
case SILInstructionKind::TryApplyInst:
350
369
case SILInstructionKind::BeginApplyInst:
0 commit comments