[llvm-commits] [llvm] r153396 - /llvm/trunk/lib/Analysis/InstructionSimplify.cpp

Chandler Carruth chandlerc at gmail.com
Sat Mar 24 15:34:24 PDT 2012


Author: chandlerc
Date: Sat Mar 24 17:34:23 2012
New Revision: 153396

URL: http://llvm.org/viewvc/llvm-project?rev=153396&view=rev
Log:
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...

Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=153396&r1=153395&r2=153396&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Sat Mar 24 17:34:23 2012
@@ -2841,7 +2841,8 @@
   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 @@
     // 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);





More information about the llvm-commits mailing list