diff options
author | Chris Lattner <sabre@nondot.org> | 2012-06-01 05:29:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2012-06-01 05:29:15 +0000 |
commit | 466076b95fb6a91c008b40e00565a1c1ff4f4ece (patch) | |
tree | 2fdc1211d66a5b34cda7f64b958a292447f0c248 /llvm/lib/CodeGen | |
parent | df09da83557720ab5ecbe496dfdd21efb8f271f0 (diff) | |
download | bcm5719-llvm-466076b95fb6a91c008b40e00565a1c1ff4f4ece.tar.gz bcm5719-llvm-466076b95fb6a91c008b40e00565a1c1ff4f4ece.zip |
enhance the logic for looking through tailcalls to look through transparent casts
in multiple-return value scenarios, like what happens on X86-64 when returning
small structs.
llvm-svn: 157800
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/Analysis.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp index dd11d15975c..1a8968dd284 100644 --- a/llvm/lib/CodeGen/Analysis.cpp +++ b/llvm/lib/CodeGen/Analysis.cpp @@ -322,7 +322,27 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, Attributes CalleeRetAttr, return false; // Otherwise, make sure the unmodified return value of I is the return value. - return getNoopInput(Ret->getOperand(0), TLI) == I; + // We handle two cases: multiple return values + scalars. + Value *RetVal = Ret->getOperand(0); + if (!isa<InsertValueInst>(RetVal) || !isa<StructType>(RetVal->getType())) + // Handle scalars first. + return getNoopInput(Ret->getOperand(0), TLI) == I; + + // If this is an aggregate return, look through the insert/extract values and + // see if each is transparent. + for (unsigned i = 0, e =cast<StructType>(RetVal->getType())->getNumElements(); + i != e; ++i) { + const Value *InScalar = getNoopInput(FindInsertedValue(RetVal, i), TLI); + + // If the scalar value being inserted is an extractvalue of the right index + // from the call, then everything is good. + const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(InScalar); + if (EVI == 0 || EVI->getOperand(0) != I || EVI->getNumIndices() != 1 || + EVI->getIndices()[0] != i) + return false; + } + + return true; } bool llvm::isInTailCallPosition(SelectionDAG &DAG, SDNode *Node, |