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

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 12 16:06:57 PST 2004



Changes in directory llvm/lib/Transforms/Utils:

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

Fix: CodeExtractor/2004-11-12-InvokeExtract.ll


---
Diffs of the changes:  (+16 -2)

Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.33 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.34
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.33	Fri Nov 12 17:50:44 2004
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp	Fri Nov 12 18:06:45 2004
@@ -488,6 +488,9 @@
             // 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();
+
+            bool DominatesDef = true;
+
             if (InvokeInst *Invoke = dyn_cast<InvokeInst>(outputs[out])) {
               DefBlock = Invoke->getNormalDest();
 
@@ -500,9 +503,18 @@
                   DefBlock = I->first;
                   break;
                 }
+
+              // In the extract block case, if the block we are extracting ends
+              // with an invoke instruction, make sure that we don't emit a
+              // store of the invoke value for the unwind block.
+              if (!DS && DefBlock != OldTarget)
+                DominatesDef = false;
             }
 
-            if (!DS || DS->dominates(DefBlock, TI->getParent()))
+            if (DS)
+              DominatesDef = DS->dominates(DefBlock, OldTarget);
+
+            if (DominatesDef) {
               if (AggregateArgs) {
                 std::vector<Value*> Indices;
                 Indices.push_back(Constant::getNullValue(Type::UIntTy));
@@ -512,8 +524,10 @@
                                         "gep_" + outputs[out]->getName(), 
                                         NTRet);
                 new StoreInst(outputs[out], GEP, NTRet);
-              } else
+              } else {
                 new StoreInst(outputs[out], OAI, NTRet);
+              }
+            }
             // Advance output iterator even if we don't emit a store
             if (!AggregateArgs) ++OAI;
           }






More information about the llvm-commits mailing list