nv50/ir: Make sure that several IR objects are destroyed on takedown.
authorFrancisco Jerez <currojerez@riseup.net>
Sat, 14 Apr 2012 19:23:03 +0000 (21:23 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 14 Apr 2012 19:54:01 +0000 (21:54 +0200)
src/gallium/drivers/nv50/codegen/nv50_ir.cpp
src/gallium/drivers/nv50/codegen/nv50_ir.h
src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp

index 4e270c5..a93dc73 100644 (file)
@@ -873,8 +873,11 @@ Program::Program(Type type, Target *arch)
 
 Program::~Program()
 {
-   if (main)
-      delete main;
+   for (ArrayList::Iterator it = allFuncs.iterator(); !it.end(); it.next())
+      delete reinterpret_cast<Function *>(it.get());
+
+   for (ArrayList::Iterator it = allRValues.iterator(); !it.end(); it.next())
+      releaseValue(reinterpret_cast<Value *>(it.get()));
 }
 
 void Program::releaseInstruction(Instruction *insn)
@@ -897,6 +900,8 @@ void Program::releaseInstruction(Instruction *insn)
 
 void Program::releaseValue(Value *value)
 {
+   value->~Value();
+
    if (value->asLValue())
       mem_LValue.release(value);
    else
index 32511f6..8d86a9c 100644 (file)
@@ -449,6 +449,7 @@ class Value
 {
 public:
    Value();
+   virtual ~Value() { }
 
    virtual Value *clone(Function *) const { return NULL; }
 
@@ -496,6 +497,7 @@ class LValue : public Value
 public:
    LValue(Function *, DataFile file);
    LValue(Function *, LValue *);
+   ~LValue() { }
 
    virtual Value *clone(Function *) const;
 
@@ -511,6 +513,7 @@ class Symbol : public Value
 {
 public:
    Symbol(Program *, DataFile file = FILE_MEMORY_CONST, ubyte fileIdx = 0);
+   ~Symbol() { }
 
    virtual Value *clone(Function *) const;
 
@@ -543,9 +546,9 @@ public:
    ImmediateValue(Program *, uint32_t);
    ImmediateValue(Program *, float);
    ImmediateValue(Program *, double);
-
    // NOTE: not added to program with
    ImmediateValue(const ImmediateValue *, DataType ty);
+   ~ImmediateValue() { };
 
    virtual bool equals(const Value *that, bool strict) const;
 
index e766c62..e6f3c35 100644 (file)
@@ -50,6 +50,12 @@ Function::~Function()
    if (bbArray)
       delete[] bbArray;
 
+   for (ArrayList::Iterator it = allInsns.iterator(); !it.end(); it.next())
+      delete_Instruction(prog, reinterpret_cast<Instruction *>(it.get()));
+
+   for (ArrayList::Iterator it = allLValues.iterator(); !it.end(); it.next())
+      delete_Value(prog, reinterpret_cast<LValue *>(it.get()));
+
    for (ArrayList::Iterator BBs = allBBlocks.iterator(); !BBs.end(); BBs.next())
       delete reinterpret_cast<BasicBlock *>(BBs.get());
 }