@@ -487,20 +487,17 @@ static bool allCallersPassValidPointerForArgument(
487
487
488
488
// Try to prove that all Calls to F do not modify the memory pointed to by Arg,
489
489
// using alias analysis local to each caller of F.
490
- static bool isArgUnmodifiedByAllCalls (Function *F, unsigned ArgNo ,
490
+ static bool isArgUnmodifiedByAllCalls (Argument *Arg ,
491
491
FunctionAnalysisManager &FAM) {
492
- // Check if all Users of F are Calls which do not modify Arg.
493
- for (User *U : F->users ()) {
492
+ for (User *U : Arg->getParent ()->users ()) {
494
493
495
494
// Bail if we find an unexpected (non CallInst) use of the function.
496
495
auto *Call = dyn_cast<CallInst>(U);
497
496
if (!Call)
498
497
return false ;
499
498
500
- Value *ArgOp = Call->getArgOperand (ArgNo);
501
- assert (ArgOp->getType ()->isPointerTy () && " Argument must be Pointer Type!" );
502
-
503
- MemoryLocation Loc = MemoryLocation::getForArgument (Call, ArgNo, nullptr );
499
+ MemoryLocation Loc =
500
+ MemoryLocation::getForArgument (Call, Arg->getArgNo (), nullptr );
504
501
505
502
AAResults &AAR = FAM.getResult <AAManager>(*Call->getFunction ());
506
503
// Bail as soon as we find a Call where Arg may be modified.
@@ -749,7 +746,7 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
749
746
// If we can determine that no call to the Function modifies the memory
750
747
// pointed to by Arg, through alias analysis using actual arguments in the
751
748
// callers, we know that it is guaranteed to be safe to promote the argument.
752
- if (isArgUnmodifiedByAllCalls (Arg-> getParent (), Arg-> getArgNo () , FAM))
749
+ if (isArgUnmodifiedByAllCalls (Arg, FAM))
753
750
return true ;
754
751
755
752
// Otherwise, use alias analysis to check if the pointer is guaranteed to not
0 commit comments