For PR1136:
Add reference counting to ParamAttrsList and make use of it in Function,
CallInst and InvokeInst classes.

llvm-svn: 36346
diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp
index b6ff70d..e395366 100644
--- a/llvm/lib/VMCore/Function.cpp
+++ b/llvm/lib/VMCore/Function.cpp
@@ -129,6 +129,10 @@
   return PAL;
 }
 
+ParamAttrsList::~ParamAttrsList() {
+  ParamAttrsLists->RemoveNode(this);
+}
+
 //===----------------------------------------------------------------------===//
 // Function Implementation
 //===----------------------------------------------------------------------===//
@@ -162,6 +166,10 @@
   // Delete all of the method arguments and unlink from symbol table...
   ArgumentList.clear();
   delete SymTab;
+
+  // Drop our reference to the parameter attributes, if any.
+  if (ParamAttrs)
+    ParamAttrs->dropRef();
 }
 
 void Function::setParent(Module *parent) {
@@ -172,6 +180,16 @@
     LeakDetector::removeGarbageObject(this);
 }
 
+void Function::setParamAttrs(ParamAttrsList *attrs) { 
+  if (ParamAttrs)
+    ParamAttrs->dropRef();
+
+  if (attrs)
+    attrs->addRef();
+
+  ParamAttrs = attrs; 
+}
+
 const FunctionType *Function::getFunctionType() const {
   return cast<FunctionType>(getType()->getElementType());
 }