Add some constraints to use of 'returned':

1) Disallow 'returned' on parameter that is also 'sret' (no sensible semantics, as far as I can tell).
2) Conservatively disallow tail calls through 'returned' parameters that also are 'zext' or 'sext' (for consistency with treatment of other zero-extending and sign-extending operations in tail call position detection...can be revised later to handle situations that can be determined to be safe).

This is a new attribute that is not yet used, so there is no impact.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180118 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Analysis.cpp b/lib/CodeGen/Analysis.cpp
index 4731af5..e2b2067 100644
--- a/lib/CodeGen/Analysis.cpp
+++ b/lib/CodeGen/Analysis.cpp
@@ -269,6 +269,8 @@
              i != e; ++i) {
           unsigned attrInd = i - I->op_begin() + 1;
           if (cast<CallInst>(I)->paramHasAttr(attrInd, Attribute::Returned) &&
+              !cast<CallInst>(I)->paramHasAttr(attrInd, Attribute::ZExt) &&
+              !cast<CallInst>(I)->paramHasAttr(attrInd, Attribute::SExt) &&
               isNoopBitcast((*i)->getType(), I->getType(), TLI)) {
             NoopInput = *i;
             break;
@@ -282,6 +284,8 @@
              i != e; ++i) {
           unsigned attrInd = i - I->op_begin() + 1;
           if (cast<InvokeInst>(I)->paramHasAttr(attrInd, Attribute::Returned) &&
+              !cast<InvokeInst>(I)->paramHasAttr(attrInd, Attribute::ZExt) &&
+              !cast<InvokeInst>(I)->paramHasAttr(attrInd, Attribute::SExt) &&
               isNoopBitcast((*i)->getType(), I->getType(), TLI)) {
             NoopInput = *i;
             break;