Skip to content

Commit aa809e9

Browse files
committed
Address review comments 2
- Remove redundant comments - Refactor function signature - Remove unnecessary assert
1 parent 9aa4e64 commit aa809e9

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

llvm/lib/Transforms/IPO/ArgumentPromotion.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,20 +487,17 @@ static bool allCallersPassValidPointerForArgument(
487487

488488
// Try to prove that all Calls to F do not modify the memory pointed to by Arg,
489489
// using alias analysis local to each caller of F.
490-
static bool isArgUnmodifiedByAllCalls(Function *F, unsigned ArgNo,
490+
static bool isArgUnmodifiedByAllCalls(Argument *Arg,
491491
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()) {
494493

495494
// Bail if we find an unexpected (non CallInst) use of the function.
496495
auto *Call = dyn_cast<CallInst>(U);
497496
if (!Call)
498497
return false;
499498

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);
504501

505502
AAResults &AAR = FAM.getResult<AAManager>(*Call->getFunction());
506503
// 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,
749746
// If we can determine that no call to the Function modifies the memory
750747
// pointed to by Arg, through alias analysis using actual arguments in the
751748
// 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))
753750
return true;
754751

755752
// Otherwise, use alias analysis to check if the pointer is guaranteed to not

0 commit comments

Comments
 (0)