summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2008-05-01 22:27:44 +0000
committerDale Johannesen <dalej@apple.com>2008-05-01 22:27:44 +0000
commit78ffe6e939887088c267b8f1fbb5d7e852cff0c0 (patch)
tree6136fea7b01ba8a0afe638051abf779faa9753e3 /llvm/lib/Transforms
parentf8ecff2a94023ae4e58205c9af4c64595d7f3083 (diff)
downloadbcm5719-llvm-78ffe6e939887088c267b8f1fbb5d7e852cff0c0.tar.gz
bcm5719-llvm-78ffe6e939887088c267b8f1fbb5d7e852cff0c0.zip
Don't try to create PHIs of struct types. Fallout
from x86-64 calling convention work. llvm-svn: 50545
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopRotation.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp
index 51e2cd8900c..0e31ece4b34 100644
--- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp
+++ b/llvm/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<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));
}
OpenPOWER on IntegriCloud