diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-06-25 20:51:38 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-06-25 20:51:38 +0000 |
commit | 125ad17fed80330967100b8c8c0e29e6237e2239 (patch) | |
tree | 34a51a81a0d52bfe0422cd0ffc1c0dad1921cab2 /llvm/lib/Transforms | |
parent | 58163dadc5117bc42ef45ca71dd9a9e62c2c8ce2 (diff) | |
download | bcm5719-llvm-125ad17fed80330967100b8c8c0e29e6237e2239.tar.gz bcm5719-llvm-125ad17fed80330967100b8c8c0e29e6237e2239.zip |
Use foreach loop over constant operands. NFC.
A number of places had explicit loops over Constant::operands().
Just use foreach loops where possible.
llvm-svn: 240694
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/GlobalOpt.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/StripSymbols.cpp | 6 |
2 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index cc4a79fa67d..5ffe15dbd31 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -1992,11 +1992,9 @@ isSimpleEnoughValueToCommitHelper(Constant *C, // Aggregate values are safe if all their elements are. if (isa<ConstantArray>(C) || isa<ConstantStruct>(C) || isa<ConstantVector>(C)) { - for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) { - Constant *Op = cast<Constant>(C->getOperand(i)); - if (!isSimpleEnoughValueToCommit(Op, SimpleConstants, DL)) + for (Value *Op : C->operands()) + if (!isSimpleEnoughValueToCommit(cast<Constant>(Op), SimpleConstants, DL)) return false; - } return true; } diff --git a/llvm/lib/Transforms/IPO/StripSymbols.cpp b/llvm/lib/Transforms/IPO/StripSymbols.cpp index 60c95734762..a4f30c58f93 100644 --- a/llvm/lib/Transforms/IPO/StripSymbols.cpp +++ b/llvm/lib/Transforms/IPO/StripSymbols.cpp @@ -142,9 +142,9 @@ static bool OnlyUsedBy(Value *V, Value *Usr) { static void RemoveDeadConstant(Constant *C) { assert(C->use_empty() && "Constant is not dead!"); SmallPtrSet<Constant*, 4> Operands; - for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) - if (OnlyUsedBy(C->getOperand(i), C)) - Operands.insert(cast<Constant>(C->getOperand(i))); + for (Value *Op : C->operands()) + if (OnlyUsedBy(Op, C)) + Operands.insert(cast<Constant>(Op)); if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) { if (!GV->hasLocalLinkage()) return; // Don't delete non-static globals. GV->eraseFromParent(); |