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 | dc00d42bb18a6748f43c365d9bd30c1ed0e800ac (patch) | |
tree | dd9f24d6ef339a9acc0fa7ac3a56cc8c7c675e24 /lib/Transforms/Utils/InlineFunction.cpp | |
parent | a76e2f0331108805228453bfa071cc43ce1aa31e (diff) | |
download | external_llvm-dc00d42bb18a6748f43c365d9bd30c1ed0e800ac.zip external_llvm-dc00d42bb18a6748f43c365d9bd30c1ed0e800ac.tar.gz external_llvm-dc00d42bb18a6748f43c365d9bd30c1ed0e800ac.tar.bz2 |
Handle multiple return values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 5525830..6dda6d3 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/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); |