diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -756,7 +756,7 @@ /// example, all callers are direct). If safe to promote some arguments, it /// calls the DoPromotion method. static Function * -promoteArguments(Function *F, function_ref AARGetter, +promoteArguments(Function *F, AAResults &AAR, function_ref DTGetter, function_ref ACGetter, unsigned MaxElements, @@ -820,8 +820,6 @@ const DataLayout &DL = F->getParent()->getDataLayout(); - AAResults &AAR = AARGetter(*F); - // Check to see which arguments are promotable. If an argument is promotable, // add it to ArgsToPromote. DenseMap> ArgsToPromote; @@ -877,13 +875,6 @@ for (LazyCallGraph::Node &N : C) { Function &OldF = N.getFunction(); - // FIXME: This lambda must only be used with this function. We should - // skip the lambda and just get the AA results directly. - auto AARGetter = [&](Function &F) -> AAResults & { - assert(&F == &OldF && "Called with an unexpected function!"); - return FAM.getResult(F); - }; - auto DTGetter = [&](Function &F) -> DominatorTree & { assert(&F != &OldF && "Called with the obsolete function!"); return FAM.getResult(F); @@ -894,8 +885,9 @@ return &FAM.getResult(F); }; + auto &AAR = FAM.getResult(OldF); const auto &TTI = FAM.getResult(OldF); - Function *NewF = promoteArguments(&OldF, AARGetter, DTGetter, ACGetter, + Function *NewF = promoteArguments(&OldF, AAR, DTGetter, ACGetter, MaxElements, None, TTI, IsRecursive); if (!NewF) continue;