PR3835: Interaction with ABI structure passing can inhibit
readnone/readonly attributes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67224 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 9e52cbb..fd33b50 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -1467,6 +1467,9 @@
                                                 llvm::Attribute::StructRet |
                                                 llvm::Attribute::NoAlias));
     ++Index;
+    // sret disables readnone and readonly
+    FuncAttrs &= ~(llvm::Attribute::ReadOnly |
+                   llvm::Attribute::ReadNone);
     break;
 
   case ABIArgInfo::Ignore:
@@ -1493,6 +1496,9 @@
       Attributes |= llvm::Attribute::ByVal;
       Attributes |= 
         llvm::Attribute::constructAlignmentFromInt(AI.getIndirectAlign());
+      // byval disables readnone and readonly.
+      FuncAttrs &= ~(llvm::Attribute::ReadOnly |
+                     llvm::Attribute::ReadNone);
       break;
       
     case ABIArgInfo::Direct: