[llvm-commits] [llvm] r50545 - /llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp

Dale Johannesen dalej at apple.com
Thu May 1 15:27:44 PDT 2008


Author: johannes
Date: Thu May  1 17:27:44 2008
New Revision: 50545

URL: http://llvm.org/viewvc/llvm-project?rev=50545&view=rev
Log:
Don't try to create PHIs of struct types.  Fallout
from x86-64 calling convention work.


Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=50545&r1=50544&r2=50545&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Thu May  1 17:27:44 2008
@@ -249,14 +249,37 @@
     // create new PHINode for this instruction.
     Instruction *NewHeaderReplacement = NULL;
     if (usedOutsideOriginalHeader(In)) {
-      PHINode *PN = PHINode::Create(In->getType(), In->getName());
-      PN->addIncoming(In, OrigHeader);
-      PN->addIncoming(C, OrigPreHeader);
-      NewHeader->getInstList().push_front(PN);
-      NewHeaderReplacement = PN;
-    } 
-    
-    // "In" can be replaced by NPH or NH at various places.
+      const StructType *STy = dyn_cast<StructType>(In->getType());
+      if (STy) {
+        // Can't create PHI nodes for this type.  If there are any getResults
+        // not defined in this block, move them back to this block.  PHI
+        // nodes will be created for all getResults later.
+        BasicBlock::iterator InsertPoint;
+        if (InvokeInst *II = dyn_cast<InvokeInst>(In)) {
+          InsertPoint = II->getNormalDest()->begin();
+          while (isa<PHINode>(InsertPoint)) 
+            ++InsertPoint;
+        } else {
+          InsertPoint = I;  // call
+          InsertPoint++;
+        }
+        for (Value::use_iterator UI = In->use_begin(), UE = In->use_end();
+             UI != UE; ++UI) {
+          GetResultInst *InGR = cast<GetResultInst>(UI);
+          if (InGR->getParent() != OrigHeader) {
+            // move InGR to immediately follow call.  It will be picked
+            // up, cloned and PHI'd on the next iteration.
+            InGR->moveBefore(InsertPoint);
+          }
+        }
+      } else {
+        PHINode *PN = PHINode::Create(In->getType(), In->getName());
+        PN->addIncoming(In, OrigHeader);
+        PN->addIncoming(C, OrigPreHeader);
+        NewHeader->getInstList().push_front(PN);
+        NewHeaderReplacement = PN;
+      }
+    }
     LoopHeaderInfo.push_back(RenameData(In, C, NewHeaderReplacement));
   }
 





More information about the llvm-commits mailing list