summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
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
commit8ed8e3d0e6ac2124fd18ccba925420555fa9b8ec (patch)
tree11b714c5965e5b4180a8fab577c08b02d83d0cb3 /llvm/lib/Transforms
parentca2b318233f6e4fb73f9041ee0b2484ed5c0f001 (diff)
downloadbcm5719-llvm-8ed8e3d0e6ac2124fd18ccba925420555fa9b8ec.tar.gz
bcm5719-llvm-8ed8e3d0e6ac2124fd18ccba925420555fa9b8ec.zip
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. llvm-svn: 50667
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index be940254049..1a2ec9901d5 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud