diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-03-24 22:34:23 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-03-24 22:34:23 +0000 |
commit | e41fc73f088ca987a87f0bf98afef3584a5e51c4 (patch) | |
tree | 68219a1ebe156df6f5dd3c1a09d94bbfb55edab0 /llvm | |
parent | a573b2201583d2952fa9b43fbbdc66425e26548a (diff) | |
download | bcm5719-llvm-e41fc73f088ca987a87f0bf98afef3584a5e51c4.tar.gz bcm5719-llvm-e41fc73f088ca987a87f0bf98afef3584a5e51c4.zip |
Don't add the instruction about to be RAUW'ed and erased to the
worklist. This can happen in theory when an instruction uses itself,
such as a PHI node. This was spotted by inspection, and unfortunately
I've not been able to come up with a test case that would trigger it. If
anyone has ideas, let me know...
llvm-svn: 153396
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 95d02efd789..c8fb6ae595b 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2841,7 +2841,8 @@ static bool replaceAndRecursivelySimplifyImpl(Instruction *I, Value *SimpleV, if (SimpleV) { for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); UI != UE; ++UI) - Worklist.push_back(cast<Instruction>(*UI)); + if (*UI != I) + Worklist.push_back(cast<Instruction>(*UI)); // Replace the instruction with its simplified value. I->replaceAllUsesWith(SimpleV); @@ -2869,7 +2870,8 @@ static bool replaceAndRecursivelySimplifyImpl(Instruction *I, Value *SimpleV, // uses of To on the recursive step in most cases. for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); UI != UE; ++UI) - Worklist.push_back(cast<Instruction>(*UI)); + if (*UI != I) + Worklist.push_back(cast<Instruction>(*UI)); // Replace the instruction with its simplified value. I->replaceAllUsesWith(SimpleV); |