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

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 12 15:50:58 PST 2004



Changes in directory llvm/lib/Transforms/Utils:

CodeExtractor.cpp updated: 1.32 -> 1.33
---
Log message:

Fix a bug where the code extractor would get a bit confused handling invoke
instructions, setting DefBlock to a block it did not have dom info for.


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

Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.32 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.33
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.32	Wed Sep 15 12:06:42 2004
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp	Fri Nov 12 17:50:44 2004
@@ -488,8 +488,20 @@
             // For an invoke, the normal destination is the only one that is
             // dominated by the result of the invocation
             BasicBlock *DefBlock = cast<Instruction>(outputs[out])->getParent();
-            if (InvokeInst *Invoke = dyn_cast<InvokeInst>(outputs[out]))
+            if (InvokeInst *Invoke = dyn_cast<InvokeInst>(outputs[out])) {
               DefBlock = Invoke->getNormalDest();
+
+              // Make sure we are looking at the original successor block, not
+              // at a newly inserted exit block, which won't be in the dominator
+              // info.
+              for (std::map<BasicBlock*, BasicBlock*>::iterator I =
+                     ExitBlockMap.begin(), E = ExitBlockMap.end(); I != E; ++I)
+                if (DefBlock == I->second) {
+                  DefBlock = I->first;
+                  break;
+                }
+            }
+
             if (!DS || DS->dominates(DefBlock, TI->getParent()))
               if (AggregateArgs) {
                 std::vector<Value*> Indices;






More information about the llvm-commits mailing list