summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-03-21 21:01:32 +0000
committerDan Gohman <gohman@apple.com>2008-03-21 21:01:32 +0000
commita25dde6feebcedc427a1229fcb450f75fe20e331 (patch)
tree59900e2040195ba42b206a88a579b468f2d4772c /llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
parentc55b444a8f7858122f1f15605fba81c510f3824f (diff)
downloadbcm5719-llvm-a25dde6feebcedc427a1229fcb450f75fe20e331.tar.gz
bcm5719-llvm-a25dde6feebcedc427a1229fcb450f75fe20e331.zip
Handle getresult instructions in different basic blocks
from their aggregate operands by moving the getresult instructions. llvm-svn: 48657
Diffstat (limited to 'llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 8762d3dd1bc..43251c344f8 100644
--- a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -1127,6 +1127,15 @@ bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) {
// Sink address computing for memory operands into the block.
MadeChange |= OptimizeInlineAsmInst(I, &(*CI), SunkAddrs);
}
+ } else if (GetResultInst *GRI = dyn_cast<GetResultInst>(I)) {
+ // Ensure that all getresult instructions live in the same basic block
+ // as their associated struct-value instructions. Codegen requires
+ // this, as lowering only works on one basic block at a time.
+ if (Instruction *Agg = dyn_cast<Instruction>(GRI->getAggregateValue())) {
+ BasicBlock *AggBB = Agg->getParent();
+ if (AggBB != GRI->getParent())
+ GRI->moveBefore(AggBB->getTerminator());
+ }
}
}
OpenPOWER on IntegriCloud