summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-03-03 10:42:58 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-03-03 10:42:58 +0000
commit1583e99c23af03b085a052ab064a8daf794cf719 (patch)
treea2ced0a2533f9f0be58ec4470823897b5133e30d /llvm/lib/Transforms
parentd5346dcf3e34877030bcb5fe82ee79fca8f7af0f (diff)
downloadbcm5719-llvm-1583e99c23af03b085a052ab064a8daf794cf719.tar.gz
bcm5719-llvm-1583e99c23af03b085a052ab064a8daf794cf719.zip
[C++11] Add two range adaptor views to User: operands and
operand_values. The first provides a range view over operand Use objects, and the second provides a range view over the Value*s being used by those operands. The naming is "STL-style" rather than "LLVM-style" because we have historically named iterator methods STL-style, and range methods seem to have far more in common with their iterator counterparts than with "normal" APIs. Feel free to bikeshed on this one if you want, I'm happy to change these around if people feel strongly. I've switched code in SROA and LCG to exercise these mostly to ensure they work correctly -- we don't really have an easy way to unittest this and they're trivial. llvm-svn: 202687
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/SROA.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 1cb76696f18..3c245e4bd5e 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3447,9 +3447,8 @@ bool SROA::runOnAlloca(AllocaInst &AI) {
DE = S.dead_user_end();
DI != DE; ++DI) {
// Free up everything used by this instruction.
- for (User::op_iterator DOI = (*DI)->op_begin(), DOE = (*DI)->op_end();
- DOI != DOE; ++DOI)
- clobberUse(*DOI);
+ for (Use &DeadOp : (*DI)->operands())
+ clobberUse(DeadOp);
// Now replace the uses of this instruction.
(*DI)->replaceAllUsesWith(UndefValue::get((*DI)->getType()));
@@ -3498,10 +3497,10 @@ void SROA::deleteDeadInstructions(SmallPtrSet<AllocaInst*, 4> &DeletedAllocas) {
I->replaceAllUsesWith(UndefValue::get(I->getType()));
- for (User::op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI)
- if (Instruction *U = dyn_cast<Instruction>(*OI)) {
+ for (Use &Operand : I->operands())
+ if (Instruction *U = dyn_cast<Instruction>(Operand)) {
// Zero out the operand and see if it becomes trivially dead.
- *OI = 0;
+ Operand = 0;
if (isInstructionTriviallyDead(U))
DeadInsts.insert(U);
}
OpenPOWER on IntegriCloud