summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorJoseph Tremoulet <jotrem@microsoft.com>2018-06-15 16:52:40 +0000
committerJoseph Tremoulet <jotrem@microsoft.com>2018-06-15 16:52:40 +0000
commit6f406d4f022e059033b335bc024d0c652d6d8c52 (patch)
tree0d7be596ce250ed81d9b04ccd6ed9ec615f7eaed /llvm/lib/Transforms
parent4adf24502ec8c993e3da2fe0ad2f4921e5a76bb9 (diff)
downloadbcm5719-llvm-6f406d4f022e059033b335bc024d0c652d6d8c52.tar.gz
bcm5719-llvm-6f406d4f022e059033b335bc024d0c652d6d8c52.zip
[InstCombine] Avoid iteration/mutation conflict
Summary: When iterating users of a multiply in processUMulZExtIdiom, the call to setOperand in the truncation case may replace the use being visited; make sure the iterator has been advanced before doing that replacement. Reviewers: majnemer, davide Reviewed By: davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48192 llvm-svn: 334844
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 8d6beba6feb..d52ea2cf6eb 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3849,7 +3849,8 @@ static Instruction *processUMulZExtIdiom(ICmpInst &I, Value *MulVal,
// mul.with.overflow and adjust properly mask/size.
if (MulVal->hasNUsesOrMore(2)) {
Value *Mul = Builder.CreateExtractValue(Call, 0, "umul.value");
- for (User *U : MulVal->users()) {
+ for (auto UI = MulVal->user_begin(), UE = MulVal->user_end(); UI != UE;) {
+ User *U = *UI++;
if (U == &I || U == OtherVal)
continue;
if (TruncInst *TI = dyn_cast<TruncInst>(U)) {
OpenPOWER on IntegriCloud