summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-06-20 01:03:44 +0000
committerDan Gohman <gohman@apple.com>2008-06-20 01:03:44 +0000
commit2c31750cd0ebdc83a890ace97dbb6249b3abe44e (patch)
tree89b1b8915ab18a901f3ba112842e92410e4dc254 /lib/Transforms/Utils
parent88d11c03cd0aae616e32dc5c09fc72e9429fd9bd (diff)
downloadllvm-2c31750cd0ebdc83a890ace97dbb6249b3abe44e.tar.gz
llvm-2c31750cd0ebdc83a890ace97dbb6249b3abe44e.tar.bz2
llvm-2c31750cd0ebdc83a890ace97dbb6249b3abe44e.tar.xz
Teach InlineFunction how to differentiate between multiple-value
return statements and aggregate returns so that it handles both correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52519 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 2ed335c95c..e917dc80b5 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -443,8 +443,9 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// uses of the returned value.
if (!TheCall->use_empty()) {
ReturnInst *R = Returns[0];
- if (isa<StructType>(TheCall->getType())) {
- // Multiple return values.
+ if (isa<StructType>(TheCall->getType()) &&
+ TheCall->getType() != R->getOperand(0)->getType()) {
+ // Multiple-value return statements.
while (!TheCall->use_empty()) {
GetResultInst *GR = cast<GetResultInst>(TheCall->use_back());
Value *RV = R->getOperand(GR->getIndex());
@@ -509,6 +510,13 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// any users of the original call/invoke instruction.
const Type *RTy = CalledFunc->getReturnType();
const StructType *STy = dyn_cast<StructType>(RTy);
+
+ // We do special handling for multiple-value return statements. If this is
+ // a plain aggregate return, don't do the special handling.
+ if (!Returns.empty() && Returns[0]->getNumOperands() != 0 &&
+ Returns[0]->getOperand(0)->getType() == STy)
+ STy = 0;
+
if (Returns.size() > 1 || STy) {
// The PHI node should go at the front of the new basic block to merge all
// possible incoming values.