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 | c5b785b91c922bbb3d5adb4b042c976bebe00e4d (patch) | |
tree | df99957d17c3abf800bfcd821ca0da68dbddddab /lib/Analysis/InstructionSimplify.cpp | |
parent | 300361a71767ddc6502ae8fffda877da986c2f22 (diff) | |
download | external_llvm-c5b785b91c922bbb3d5adb4b042c976bebe00e4d.zip external_llvm-c5b785b91c922bbb3d5adb4b042c976bebe00e4d.tar.gz external_llvm-c5b785b91c922bbb3d5adb4b042c976bebe00e4d.tar.bz2 |
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...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 95d02ef..c8fb6ae 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/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); |