diff options
Diffstat (limited to 'lib/Transforms/Scalar/ConstantHoisting.cpp')
-rw-r--r-- | lib/Transforms/Scalar/ConstantHoisting.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/Transforms/Scalar/ConstantHoisting.cpp b/lib/Transforms/Scalar/ConstantHoisting.cpp index b4419313b0..6cfcec547d 100644 --- a/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -266,12 +266,11 @@ static void CollectBasicBlocks(SmallPtrSet<BasicBlock *, 4> &BBs, Function &F, BBs.insert(I->getParent()); else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(U)) // Find all users of this constant expression. - for (Value::use_iterator UU = CE->use_begin(), E = CE->use_end(); - UU != E; ++UU) + for (User *UU : CE->users()) // Only record users that are instructions. We don't want to go down a // nested constant expression chain. Also check if the instruction is even // in the current function. - if (Instruction *I = dyn_cast<Instruction>(*UU)) + if (Instruction *I = dyn_cast<Instruction>(UU)) if(I->getParent()->getParent() == &F) BBs.insert(I->getParent()); } @@ -350,12 +349,11 @@ void ConstantHoisting::EmitBaseConstants(Function &F, User *U, ConstantExpr *CE = cast<ConstantExpr>(U); SmallVector<std::pair<Instruction *, Instruction *>, 8> WorkList; DEBUG(dbgs() << "Visit ConstantExpr " << *CE << '\n'); - for (Value::use_iterator UU = CE->use_begin(), E = CE->use_end(); - UU != E; ++UU) { + for (User *UU : CE->users()) { DEBUG(dbgs() << "Check user "; UU->print(dbgs()); dbgs() << '\n'); // We only handel instructions here and won't walk down a ConstantExpr chain // to replace all ConstExpr with instructions. - if (Instruction *I = dyn_cast<Instruction>(*UU)) { + if (Instruction *I = dyn_cast<Instruction>(UU)) { // Only update constant expressions in the current function. if (I->getParent()->getParent() != &F) { DEBUG(dbgs() << "Not in the same function - skip.\n"); @@ -423,9 +421,9 @@ bool ConstantHoisting::EmitBaseConstants(Function &F) { // Use the same debug location as the last user of the constant. assert(!Base->use_empty() && "The use list is empty!?"); - assert(isa<Instruction>(Base->use_back()) && + assert(isa<Instruction>(Base->user_back()) && "All uses should be instructions."); - Base->setDebugLoc(cast<Instruction>(Base->use_back())->getDebugLoc()); + Base->setDebugLoc(cast<Instruction>(Base->user_back())->getDebugLoc()); // Correct for base constant, which we counted above too. NumConstantsRebased--; |