diff options
author | Brian Gesiak <modocache@gmail.com> | 2018-02-19 22:48:51 +0000 |
---|---|---|
committer | Brian Gesiak <modocache@gmail.com> | 2018-02-19 22:48:51 +0000 |
commit | d1eabb1810dc311965cb26f8ec359a3d1b23a55f (patch) | |
tree | ccce4d2f080f563abcae583a32c037a35aaa5c4f /llvm/lib/Transforms/Utils | |
parent | c1e5c218e65736a87e4f25da33de343001bb2b36 (diff) | |
download | bcm5719-llvm-d1eabb1810dc311965cb26f8ec359a3d1b23a55f.tar.gz bcm5719-llvm-d1eabb1810dc311965cb26f8ec359a3d1b23a55f.zip |
Revert "[mem2reg] Use range loops (NFCI)"
This reverts commit r325532.
llvm-svn: 325539
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index ac85cafb268..fcd3bd08482 100644 --- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -136,8 +136,8 @@ struct AllocaInfo { // 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 (User *U : AI->users()) { - Instruction *User = cast<Instruction>(U); + for (auto UI = AI->user_begin(), E = AI->user_end(); UI != E;) { + Instruction *User = cast<Instruction>(*UI++); if (StoreInst *SI = dyn_cast<StoreInst>(User)) { // Remember the basic blocks which define new values for the alloca @@ -325,8 +325,9 @@ static void removeLifetimeIntrinsicUsers(AllocaInst *AI) { // Knowing that this alloca is promotable, we know that it's safe to kill all // instructions except for load and store. - for (User *U : AI->users()) { - Instruction *I = cast<Instruction>(U); + for (auto UI = AI->user_begin(), UE = AI->user_end(); UI != UE;) { + Instruction *I = cast<Instruction>(*UI); + ++UI; if (isa<LoadInst>(I) || isa<StoreInst>(I)) continue; @@ -363,8 +364,8 @@ static bool rewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info, // Clear out UsingBlocks. We will reconstruct it here if needed. Info.UsingBlocks.clear(); - for (User *U : AI->users()) { - Instruction *UserInst = cast<Instruction>(U); + for (auto UI = AI->user_begin(), E = AI->user_end(); UI != E;) { + Instruction *UserInst = cast<Instruction>(*UI++); if (!isa<LoadInst>(UserInst)) { assert(UserInst == OnlyStore && "Should only have load/stores"); continue; @@ -478,8 +479,8 @@ static bool promoteSingleBlockAlloca(AllocaInst *AI, const AllocaInfo &Info, // Walk all of the loads from this alloca, replacing them with the nearest // store above them, if any. - for (User *U : AI->users()) { - LoadInst *LI = dyn_cast<LoadInst>(U); + for (auto UI = AI->user_begin(), E = AI->user_end(); UI != E;) { + LoadInst *LI = dyn_cast<LoadInst>(*UI++); if (!LI) continue; |