@@ -441,16 +441,24 @@ mayGuaranteedUseValue(SILInstruction *User, SILValue Ptr, AliasAnalysis *AA) {
441
441
442
442
FullApplySite FAS (User);
443
443
444
- // Ok, we have a full apply site. If the apply has no arguments, we don't need
445
- // to worry about any guaranteed parameters.
444
+ // Ok, we have a full apply site. Check if the callee is callee_guaranteed. In
445
+ // such a case, if we can not prove no alias, we need to be conservative and
446
+ // return true.
447
+ CanSILFunctionType FType = FAS.getSubstCalleeType ();
448
+ if (FType->isCalleeGuaranteed () && !AA->isNoAlias (FAS.getCallee (), Ptr)) {
449
+ return true ;
450
+ }
451
+
452
+ // Ok, we have a full apply site and our callee is a normal use. Thus if the
453
+ // apply does not have any normal arguments, we don't need to worry about any
454
+ // guaranteed parameters and return early.
446
455
if (!FAS.getNumArguments ())
447
456
return false ;
448
457
449
458
// Ok, we have an apply site with arguments. Look at the function type and
450
459
// iterate through the function parameters. If any of the parameters are
451
460
// guaranteed, attempt to prove that the passed in parameter cannot alias
452
461
// Ptr. If we fail, return true.
453
- CanSILFunctionType FType = FAS.getSubstCalleeType ();
454
462
auto Params = FType->getParameters ();
455
463
for (unsigned i : indices (Params)) {
456
464
if (!Params[i].isGuaranteed ())
0 commit comments