Index: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp =================================================================== --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -136,8 +136,8 @@ // As we scan the uses of the alloca instruction, keep track of stores, // and decide whether all of the loads and stores to the alloca are within // the same basic block. - for (auto UI = AI->user_begin(), E = AI->user_end(); UI != E;) { - Instruction *User = cast(*UI++); + for (User *U : AI->users()) { + Instruction *User = cast(U); if (StoreInst *SI = dyn_cast(User)) { // Remember the basic blocks which define new values for the alloca @@ -325,9 +325,8 @@ // Knowing that this alloca is promotable, we know that it's safe to kill all // instructions except for load and store. - for (auto UI = AI->user_begin(), UE = AI->user_end(); UI != UE;) { - Instruction *I = cast(*UI); - ++UI; + for (User *U : AI->users()) { + Instruction *I = cast(U); if (isa(I) || isa(I)) continue; @@ -364,8 +363,8 @@ // Clear out UsingBlocks. We will reconstruct it here if needed. Info.UsingBlocks.clear(); - for (auto UI = AI->user_begin(), E = AI->user_end(); UI != E;) { - Instruction *UserInst = cast(*UI++); + for (User *U : AI->users()) { + Instruction *UserInst = cast(U); if (!isa(UserInst)) { assert(UserInst == OnlyStore && "Should only have load/stores"); continue; @@ -479,8 +478,8 @@ // Walk all of the loads from this alloca, replacing them with the nearest // store above them, if any. - for (auto UI = AI->user_begin(), E = AI->user_end(); UI != E;) { - LoadInst *LI = dyn_cast(*UI++); + for (User *U : AI->users()) { + LoadInst *LI = dyn_cast(U); if (!LI) continue;