Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls.  This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll).  Hopefully
a bitcode guru (who might that be? :) ) will fix it.

llvm-svn: 44359
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 6bee186..7226f66 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -35,6 +35,18 @@
   else
     cast<InvokeInst>(I)->setCallingConv(CC);
 }
+const ParamAttrsList* CallSite::getParamAttrs() const {
+  if (CallInst *CI = dyn_cast<CallInst>(I))
+    return CI->getParamAttrs();
+  else
+    return cast<InvokeInst>(I)->getParamAttrs();
+}
+void CallSite::setParamAttrs(const ParamAttrsList *PAL) {
+  if (CallInst *CI = dyn_cast<CallInst>(I))
+    CI->setParamAttrs(PAL);
+  else
+    cast<InvokeInst>(I)->setParamAttrs(PAL);
+}
 
 
 
@@ -341,8 +353,9 @@
 
 CallInst::CallInst(const CallInst &CI)
   : Instruction(CI.getType(), Instruction::Call, new Use[CI.getNumOperands()],
-                CI.getNumOperands()) {
-  ParamAttrs = 0;
+                CI.getNumOperands()),
+    ParamAttrs(0) {
+  setParamAttrs(CI.getParamAttrs());
   SubclassData = CI.SubclassData;
   Use *OL = OperandList;
   Use *InOL = CI.OperandList;
@@ -350,7 +363,10 @@
     OL[i].init(InOL[i], this);
 }
 
-void CallInst::setParamAttrs(ParamAttrsList *newAttrs) {
+void CallInst::setParamAttrs(const ParamAttrsList *newAttrs) {
+  if (ParamAttrs == newAttrs)
+    return;
+
   if (ParamAttrs)
     ParamAttrs->dropRef();
 
@@ -360,6 +376,12 @@
   ParamAttrs = newAttrs; 
 }
 
+bool CallInst::isStructReturn() const {
+  if (ParamAttrs)
+    return ParamAttrs->paramHasAttr(1, ParamAttr::StructRet);
+  return false;
+}
+
 //===----------------------------------------------------------------------===//
 //                        InvokeInst Implementation
 //===----------------------------------------------------------------------===//
@@ -397,8 +419,9 @@
 
 InvokeInst::InvokeInst(const InvokeInst &II)
   : TerminatorInst(II.getType(), Instruction::Invoke,
-                   new Use[II.getNumOperands()], II.getNumOperands()) {
-  ParamAttrs = 0;
+                   new Use[II.getNumOperands()], II.getNumOperands()),
+    ParamAttrs(0) {
+  setParamAttrs(II.getParamAttrs());
   SubclassData = II.SubclassData;
   Use *OL = OperandList, *InOL = II.OperandList;
   for (unsigned i = 0, e = II.getNumOperands(); i != e; ++i)
@@ -415,7 +438,10 @@
   return setSuccessor(idx, B);
 }
 
-void InvokeInst::setParamAttrs(ParamAttrsList *newAttrs) {
+void InvokeInst::setParamAttrs(const ParamAttrsList *newAttrs) {
+  if (ParamAttrs == newAttrs)
+    return;
+
   if (ParamAttrs)
     ParamAttrs->dropRef();
 
@@ -425,6 +451,12 @@
   ParamAttrs = newAttrs; 
 }
 
+bool InvokeInst::isStructReturn() const {
+  if (ParamAttrs)
+    return ParamAttrs->paramHasAttr(1, ParamAttr::StructRet);
+  return false;
+}
+
 //===----------------------------------------------------------------------===//
 //                        ReturnInst Implementation
 //===----------------------------------------------------------------------===//