For PR1146:
authorReid Spencer <rspencer@reidspencer.com>
Mon, 9 Apr 2007 18:00:57 +0000 (18:00 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 9 Apr 2007 18:00:57 +0000 (18:00 +0000)
* Add ParamAttrs to InvokeInst class too.
* Make sure all initializes of ParamAttrs in CallInst and InvokeInst are 0
* Destruct the ParamAttrs in Call/Invoke destructors to avoid memory
  leaks. This will change when ParamAttrsList is uniquified but needs to
  be correct until then.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35824 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instructions.h
lib/VMCore/Instructions.cpp

index a25dd128ef2ec56084dd6e1307673f366c892293..8f3b24a1e6f6cc7511eb426ccb710aaebc852e1a 100644 (file)
@@ -737,10 +737,11 @@ public:
     SubclassData = (SubclassData & 1) | (CC << 1);
   }
 
-  /// Obtains a constant pointer to the ParamAttrsList object which holds the
-  /// parameter attributes information, if any. 
+  /// Obtains a pointer to the ParamAttrsList object which holds the
+  /// parameter attributes information, if any.
+  /// @returns 0 if no attributes have been set.
   /// @brief Get the parameter attributes.
-  const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+  ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
 
   /// Sets the parameter attributes for this CallInst. To construct a 
   /// ParamAttrsList, see ParameterAttributes.h
@@ -1445,6 +1446,7 @@ private:
 /// calling convention of the call.
 ///
 class InvokeInst : public TerminatorInst {
+  ParamAttrsList *ParamAttrs;
   InvokeInst(const InvokeInst &BI);
   void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
             Value* const *Args, unsigned NumArgs);
@@ -1466,6 +1468,17 @@ public:
     SubclassData = CC;
   }
 
+  /// Obtains a pointer to the ParamAttrsList object which holds the
+  /// parameter attributes information, if any.
+  /// @returns 0 if no attributes have been set.
+  /// @brief Get the parameter attributes.
+  ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+
+  /// Sets the parameter attributes for this InvokeInst. To construct a 
+  /// ParamAttrsList, see ParameterAttributes.h
+  /// @brief Set the parameter attributes.
+  void setParamAttrs(ParamAttrsList *attrs) { ParamAttrs = attrs; }
+
   /// getCalledFunction - Return the function called, or null if this is an
   /// indirect function invocation.
   ///
index c09ec3ce217151cca29ff32400a3a6b9f1b51214..f9aa3e7b2d25a9c99267c95238a044707f2b4cdf 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
 #include "llvm/Instructions.h"
+#include "llvm/ParameterAttributes.h"
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/ConstantRange.h"
 using namespace llvm;
@@ -185,6 +186,7 @@ Value *PHINode::hasConstantValue(bool AllowNonDominatingInstruction) const {
 
 CallInst::~CallInst() {
   delete [] OperandList;
+  delete ParamAttrs; // FIXME: ParamAttrsList should be uniqued!
 }
 
 void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
@@ -337,6 +339,7 @@ CallInst::CallInst(Value *Func, const std::string &Name,
 CallInst::CallInst(const CallInst &CI)
   : Instruction(CI.getType(), Instruction::Call, new Use[CI.getNumOperands()],
                 CI.getNumOperands()) {
+  ParamAttrs = 0;
   SubclassData = CI.SubclassData;
   Use *OL = OperandList;
   Use *InOL = CI.OperandList;
@@ -351,10 +354,12 @@ CallInst::CallInst(const CallInst &CI)
 
 InvokeInst::~InvokeInst() {
   delete [] OperandList;
+  delete ParamAttrs; // FIXME: ParamAttrsList should be uniqued!
 }
 
 void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
                       Value* const *Args, unsigned NumArgs) {
+  ParamAttrs = 0;
   NumOperands = 3+NumArgs;
   Use *OL = OperandList = new Use[3+NumArgs];
   OL[0].init(Fn, this);
@@ -402,6 +407,7 @@ InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
 InvokeInst::InvokeInst(const InvokeInst &II)
   : TerminatorInst(II.getType(), Instruction::Invoke,
                    new Use[II.getNumOperands()], II.getNumOperands()) {
+  ParamAttrs = 0;
   SubclassData = II.SubclassData;
   Use *OL = OperandList, *InOL = II.OperandList;
   for (unsigned i = 0, e = II.getNumOperands(); i != e; ++i)