[llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Mar 17 23:39:02 PST 2004


Changes in directory llvm/lib/Transforms/Utils:

CodeExtractor.cpp updated: 1.14 -> 1.15

---
Log message:

Fix CodeExtractor/2004-03-17-UpdatePHIsOutsideRegion.ll


---
Diffs of the changes:  (+13 -0)

Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.14 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.15
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.14	Wed Mar 17 23:28:49 2004
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp	Wed Mar 17 23:38:31 2004
@@ -371,6 +371,19 @@
       if (!BlocksToExtract.count(PN->getIncomingBlock(i)))
         PN->setIncomingBlock(i, newFuncRoot);
 
+  // Look at all successors of the codeReplacer block.  If any of these blocks
+  // had PHI nodes in them, we need to update the "from" block to be the code
+  // replacer, not the original block in the extracted region.
+  std::vector<BasicBlock*> Succs(succ_begin(codeReplacer),
+                                 succ_end(codeReplacer));
+  for (unsigned i = 0, e = Succs.size(); i != e; ++i)
+    for (BasicBlock::iterator I = Succs[i]->begin();
+         PHINode *PN = dyn_cast<PHINode>(I); ++I)
+      for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
+        if (BlocksToExtract.count(PN->getIncomingBlock(i)))
+          PN->setIncomingBlock(i, codeReplacer);
+  
+
   DEBUG(if (verifyFunction(*newFunction)) abort());
   return newFunction;
 }





More information about the llvm-commits mailing list