[llvm] r180118 - Add some constraints to use of 'returned':

Stephen Lin stephenwlin at gmail.com
Tue Apr 23 09:31:56 PDT 2013


Author: stephenwlin
Date: Tue Apr 23 11:31:56 2013
New Revision: 180118

URL: http://llvm.org/viewvc/llvm-project?rev=180118&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/CodeGen/Analysis.cpp
    llvm/trunk/lib/IR/Verifier.cpp

Modified: llvm/trunk/lib/CodeGen/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Analysis.cpp?rev=180118&r1=180117&r2=180118&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/Analysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/Analysis.cpp Tue Apr 23 11:31:56 2013
@@ -269,6 +269,8 @@ static bool sameNoopInput(const Value *V
              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 @@ static bool sameNoopInput(const Value *V
              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;

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=180118&r1=180117&r2=180118&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Tue Apr 23 11:31:56 2013
@@ -740,6 +740,10 @@ void Verifier::VerifyParameterAttrs(Attr
              Attrs.hasAttribute(Idx, Attribute::InReg))), "Attributes "
           "'byval, nest, and inreg' are incompatible!", V);
 
+  Assert1(!(Attrs.hasAttribute(Idx, Attribute::StructRet) &&
+            Attrs.hasAttribute(Idx, Attribute::Returned)), "Attributes "
+          "'sret and returned' are incompatible!", V);
+
   Assert1(!(Attrs.hasAttribute(Idx, Attribute::ZExt) &&
             Attrs.hasAttribute(Idx, Attribute::SExt)), "Attributes "
           "'zeroext and signext' are incompatible!", V);





More information about the llvm-commits mailing list