From: Dale Johannesen Date: Thu, 1 May 2008 22:27:44 +0000 (+0000) Subject: Don't try to create PHIs of struct types. Fallout X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=796026711db8342aead8d85cdd50d0dc2da59c4c;p=oota-llvm.git Don't try to create PHIs of struct types. Fallout from x86-64 calling convention work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50545 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopRotation.cpp b/lib/Transforms/Scalar/LoopRotation.cpp index 51e2cd8900c..0e31ece4b34 100644 --- a/lib/Transforms/Scalar/LoopRotation.cpp +++ b/lib/Transforms/Scalar/LoopRotation.cpp @@ -249,14 +249,37 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) { // 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(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(In)) { + InsertPoint = II->getNormalDest()->begin(); + while (isa(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(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)); }