summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
authorStepan Dyatkovskiy <stpworld@narod.ru>2011-11-29 20:34:39 +0000
committerStepan Dyatkovskiy <stpworld@narod.ru>2011-11-29 20:34:39 +0000
commitbe4c84464892ea0a4bf51773502f2b0a086fe184 (patch)
treedf9dc67eefbc0925657dd743c0496bf8c5eea588 /lib/Transforms/Scalar/LoopUnswitch.cpp
parentfe2cb3e37f20103e14eabff08f3453a4bb6d8251 (diff)
downloadllvm-be4c84464892ea0a4bf51773502f2b0a086fe184.tar.gz
llvm-be4c84464892ea0a4bf51773502f2b0a086fe184.tar.bz2
llvm-be4c84464892ea0a4bf51773502f2b0a086fe184.tar.xz
Potential bug in RewriteLoopBodyWithConditionConstant: use iterator should not be changed inside the uses enumeration loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145432 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 458949c844..ab70dd5e42 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -907,9 +907,13 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,
Instruction *U = dyn_cast<Instruction>(*UI);
if (!U || !L->contains(U))
continue;
- U->replaceUsesOfWith(LIC, Replacement);
Worklist.push_back(U);
}
+
+ for (std::vector<Instruction*>::iterator UI = Worklist.begin();
+ UI != Worklist.end(); ++UI)
+ (*UI)->replaceUsesOfWith(LIC, Replacement);
+
SimplifyCode(Worklist, L);
return;
}