aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-04-22 17:28:03 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-04-22 17:28:03 +0000
commitb90909e40536db17665727f5ca1c618e485464c3 (patch)
tree770b735b61c9866050ceb8d3705dc80a582d70a8 /lib/VMCore
parent7aaa4a5c09d7c9a53ccf2c856c8ba6fe31f14302 (diff)
downloadexternal_llvm-b90909e40536db17665727f5ca1c618e485464c3.zip
external_llvm-b90909e40536db17665727f5ca1c618e485464c3.tar.gz
external_llvm-b90909e40536db17665727f5ca1c618e485464c3.tar.bz2
For PR1136:
Add reference counting to ParamAttrsList and make use of it in Function, CallInst and InvokeInst classes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Function.cpp18
-rw-r--r--lib/VMCore/Instructions.cpp22
2 files changed, 40 insertions, 0 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index b6ff70d..e395366 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -129,6 +129,10 @@ ParamAttrsList::get(const ParamAttrsVector &attrVec) {
return PAL;
}
+ParamAttrsList::~ParamAttrsList() {
+ ParamAttrsLists->RemoveNode(this);
+}
+
//===----------------------------------------------------------------------===//
// Function Implementation
//===----------------------------------------------------------------------===//
@@ -162,6 +166,10 @@ Function::~Function() {
// 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 @@ void Function::setParent(Module *parent) {
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());
}
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 3bb565d..e0c2a5e 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -186,6 +186,8 @@ Value *PHINode::hasConstantValue(bool AllowNonDominatingInstruction) const {
CallInst::~CallInst() {
delete [] OperandList;
+ if (ParamAttrs)
+ ParamAttrs->dropRef();
}
void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
@@ -346,6 +348,15 @@ CallInst::CallInst(const CallInst &CI)
OL[i].init(InOL[i], this);
}
+void CallInst::setParamAttrs(ParamAttrsList *newAttrs) {
+ if (ParamAttrs)
+ ParamAttrs->dropRef();
+
+ if (newAttrs)
+ newAttrs->addRef();
+
+ ParamAttrs = newAttrs;
+}
//===----------------------------------------------------------------------===//
// InvokeInst Implementation
@@ -353,6 +364,8 @@ CallInst::CallInst(const CallInst &CI)
InvokeInst::~InvokeInst() {
delete [] OperandList;
+ if (ParamAttrs)
+ ParamAttrs->dropRef();
}
void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
@@ -422,6 +435,15 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
return setSuccessor(idx, B);
}
+void InvokeInst::setParamAttrs(ParamAttrsList *newAttrs) {
+ if (ParamAttrs)
+ ParamAttrs->dropRef();
+
+ if (newAttrs)
+ newAttrs->addRef();
+
+ ParamAttrs = newAttrs;
+}
//===----------------------------------------------------------------------===//
// ReturnInst Implementation