aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-05-05 20:21:22 +0000
committerChris Lattner <sabre@nondot.org>2008-05-05 20:21:22 +0000
commit8554cc2ea79861ddf43998bff634d1682e848216 (patch)
tree4d5578884f6da0f9c6182ce10857dda021e78148 /lib/Transforms/Scalar/JumpThreading.cpp
parentbe5918c079c208af24fa3501f883ecceb6e6ae02 (diff)
Fix a crash when threading a block that includes a MRV call result.
DemoteRegToStack doesn't work with MRVs yet, because it relies on the ability to load/store things. This fixes PR2285. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50667 91177308-0d34-0410-b5e6-96231b3b80d8
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