aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index be94025404..1a2ec9901d 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -433,12 +433,27 @@ void JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
// Jump Threading can not update SSA properties correctly if the values
// defined in the duplicated block are used outside of the block itself. For
// this reason, we spill all values that are used outside of BB to the stack.
- for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I)
- if (I->isUsedOutsideOfBlock(BB)) {
- // We found a use of I outside of BB. Create a new stack slot to
- // break this inter-block usage pattern.
+ for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
+ if (!I->isUsedOutsideOfBlock(BB))
+ continue;
+
+ // We found a use of I outside of BB. Create a new stack slot to
+ // break this inter-block usage pattern.
+ if (!isa<StructType>(I->getType())) {
DemoteRegToStack(*I);
+ continue;
}
+
+ // Alternatively, I must be a call or invoke that returns multiple retvals.
+ // We can't use 'DemoteRegToStack' because the at will create loads and
+ // stores of aggregates which is not valid yet. If I is a call, we can just
+ // pull all the getresult instructions up to this block. If I is an invoke,
+ // we are out of luck.
+ BasicBlock::iterator IP = I; ++IP;
+ for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
+ UI != E; ++UI)
+ cast<GetResultInst>(UI)->moveBefore(IP);
+ }
// We are going to have to map operands from the original BB block to the new
// copy of the block 'NewBB'. If there are PHI nodes in BB, evaluate them to