[llvm] r274973 - [ArgPromote] Use function_ref and for-range loops.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 9 03:36:37 PDT 2016
Author: d0k
Date: Sat Jul 9 05:36:36 2016
New Revision: 274973
URL: http://llvm.org/viewvc/llvm-project?rev=274973&view=rev
Log:
[ArgPromote] Use function_ref and for-range loops.
No functionality change intended.
Modified:
llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=274973&r1=274972&r2=274973&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Sat Jul 9 05:36:36 2016
@@ -94,7 +94,7 @@ typedef std::vector<uint64_t> IndicesVec
static CallGraphNode *
PromoteArguments(CallGraphNode *CGN, CallGraph &CG,
- std::function<AAResults &(Function &F)> AARGetter,
+ function_ref<AAResults &(Function &F)> AARGetter,
unsigned MaxElements);
static bool isDenselyPacked(Type *type, const DataLayout &DL);
static bool canPaddingBeAccessed(Argument *Arg);
@@ -118,18 +118,18 @@ Pass *llvm::createArgumentPromotionPass(
}
static bool runImpl(CallGraphSCC &SCC, CallGraph &CG,
- std::function<AAResults &(Function &F)> &AARGetter,
+ function_ref<AAResults &(Function &F)> AARGetter,
unsigned MaxElements) {
bool Changed = false, LocalChange;
do { // Iterate until we stop promoting from this SCC.
LocalChange = false;
// Attempt to promote arguments from all functions in this SCC.
- for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
- if (CallGraphNode *CGN =
- PromoteArguments(*I, CG, AARGetter, MaxElements)) {
+ for (CallGraphNode *OldNode : SCC) {
+ if (CallGraphNode *NewNode =
+ PromoteArguments(OldNode, CG, AARGetter, MaxElements)) {
LocalChange = true;
- SCC.ReplaceNode(*I, CGN);
+ SCC.ReplaceNode(OldNode, NewNode);
}
}
Changed |= LocalChange; // Remember that we changed something.
@@ -151,8 +151,7 @@ bool ArgPromotion::runOnSCC(CallGraphSCC
// be queried, but we re-use them each time.
Optional<BasicAAResult> BAR;
Optional<AAResults> AAR;
- std::function<AAResults &(Function & F)> AARGetter = [&](
- Function &F) -> AAResults & {
+ auto AARGetter = [&](Function &F) -> AAResults & {
BAR.emplace(createLegacyPMBasicAAResult(*this, F));
AAR.emplace(createLegacyPMAAResults(*this, F, *BAR));
return *AAR;
@@ -241,7 +240,7 @@ static bool canPaddingBeAccessed(Argumen
///
static CallGraphNode *
PromoteArguments(CallGraphNode *CGN, CallGraph &CG,
- std::function<AAResults &(Function &F)> AARGetter,
+ function_ref<AAResults &(Function &F)> AARGetter,
unsigned MaxElements) {
Function *F = CGN->getFunction();
@@ -283,8 +282,7 @@ PromoteArguments(CallGraphNode *CGN, Cal
// add it to ArgsToPromote.
SmallPtrSet<Argument*, 8> ArgsToPromote;
SmallPtrSet<Argument*, 8> ByValArgsToTransform;
- for (unsigned i = 0, e = PointerArgs.size(); i != e; ++i) {
- Argument *PtrArg = PointerArgs[i];
+ for (Argument *PtrArg : PointerArgs) {
Type *AgTy = cast<PointerType>(PtrArg->getType())->getElementType();
// Replace sret attribute with noalias. This reduces register pressure by
@@ -604,10 +602,9 @@ static bool isSafeToPromoteArgument(Argu
// blocks we know to be transparent to the load.
SmallPtrSet<BasicBlock*, 16> TranspBlocks;
- for (unsigned i = 0, e = Loads.size(); i != e; ++i) {
+ for (LoadInst *Load : Loads) {
// Check to see if the load is invalidated from the start of the block to
// the load itself.
- LoadInst *Load = Loads[i];
BasicBlock *BB = Load->getParent();
MemoryLocation Loc = MemoryLocation::get(Load);
More information about the llvm-commits
mailing list