diff options
| author | Devang Patel <dpatel@apple.com> | 2008-03-04 21:15:15 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2008-03-04 21:15:15 +0000 |
| commit | 841322b32a93a24cb0c09500dab301e591327c79 (patch) | |
| tree | 78aaaef84dc8d3d94d4f0c2021b096d87fd55ae5 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
| parent | 4fee9f35b5f08c734d5ac78e323f7583c6f658e0 (diff) | |
| download | bcm5719-llvm-841322b32a93a24cb0c09500dab301e591327c79.tar.gz bcm5719-llvm-841322b32a93a24cb0c09500dab301e591327c79.zip | |
Handle multiple return values.
llvm-svn: 47904
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 552583042a7..6dda6d3313a 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -442,9 +442,21 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) { // If the return instruction returned a value, replace uses of the call with // uses of the returned value. - if (!TheCall->use_empty()) - TheCall->replaceAllUsesWith(Returns[0]->getReturnValue()); - + if (!TheCall->use_empty()) { + ReturnInst *R = Returns[0]; + if (R->getNumOperands() > 1) { + // Multiple return values. + for (Value::use_iterator RUI = TheCall->use_begin(), + RUE = TheCall->use_end(); RUI != RUE; ) { + GetResultInst *GR = dyn_cast<GetResultInst>(RUI++); + assert (GR && "Invalid Call instruction use!"); + Value *RV = R->getOperand(GR->getIndex()); + GR->replaceAllUsesWith(RV); + GR->eraseFromParent(); + } + } else + TheCall->replaceAllUsesWith(R->getReturnValue()); + } // Since we are now done with the Call/Invoke, we can delete it. TheCall->getParent()->getInstList().erase(TheCall); |

