diff options
author | Devang Patel <dpatel@apple.com> | 2008-05-03 01:12:15 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-05-03 01:12:15 +0000 |
commit | 7b399695289793c57196b66d71d5e965639e920c (patch) | |
tree | b0e36cc80bda3ce5fe9804f07ee544ad6d1fc54b /lib/Transforms/Utils/LCSSA.cpp | |
parent | 7a07428ad1015306d7235cabebd5f4f78e62d33c (diff) | |
download | external_llvm-7b399695289793c57196b66d71d5e965639e920c.zip external_llvm-7b399695289793c57196b66d71d5e965639e920c.tar.gz external_llvm-7b399695289793c57196b66d71d5e965639e920c.tar.bz2 |
Handle multiple return values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50604 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r-- | lib/Transforms/Utils/LCSSA.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index a9d1dc4..3931467 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -217,7 +217,29 @@ void LCSSA::getLoopValuesUsedOutsideLoop(Loop *L, } if (*BB != UserBB && !inLoop(UserBB)) { - AffectedValues.insert(I); + const StructType *STy = dyn_cast<StructType>(I->getType()); + if (STy) { + // I is a call or an invoke that returns multiple values. + // These values are accessible through getresult only. + // If the getresult value is not in the BB then move it + // immediately here. It will be processed in next iteration. + BasicBlock::iterator InsertPoint; + if (InvokeInst *II = dyn_cast<InvokeInst>(I)) { + InsertPoint = II->getNormalDest()->begin(); + while (isa<PHINode>(InsertPoint)) + ++InsertPoint; + } else { + InsertPoint = I; + InsertPoint++; + } + for (Value::use_iterator TmpI = I->use_begin(), + TmpE = I->use_end(); TmpI != TmpE; ++TmpI) { + GetResultInst *GR = cast<GetResultInst>(TmpI); + if (GR->getParent() != *BB) + GR->moveBefore(InsertPoint); + } + } else + AffectedValues.insert(I); break; } } |