[Beignet] [PATCH] Backend: Fix a memory leak for structurizer.
junyan.he at inbox.com
junyan.he at inbox.com
Sun Dec 13 22:51:26 PST 2015
From: Junyan He <junyan.he at linux.intel.com>
In structurizer, the useless instruction is just be
erased from block. The iintrusive_list::erase() just
unlink the instruction, but not free its resource.
We should use remove() to deallocate the instruction
object.
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
backend/src/ir/structurizer.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/backend/src/ir/structurizer.cpp b/backend/src/ir/structurizer.cpp
index 38d3dd1..749cb94 100644
--- a/backend/src/ir/structurizer.cpp
+++ b/backend/src/ir/structurizer.cpp
@@ -57,7 +57,7 @@ namespace ir {
Instruction* p_new_insn = pbb->getParent().newInstruction(insn);
pbb->insertAt(it, *p_new_insn);
pbb->whileLabel = whileLabel;
- pbb->erase(it);
+ it->remove();
}
/* recursive mark the bbs' variable needEndif*/
@@ -122,7 +122,7 @@ namespace ir {
/* since this block is an if block, so we remove the BRA instruction at the bottom of the exit BB of 'block',
* and insert IF instead
*/
- pbb->erase(it);
+ it->remove();
Instruction insn = IF(matchingElseLabel, reg, block->inversePredicate);
Instruction* p_new_insn = pbb->getParent().newInstruction(insn);
pbb->append(*p_new_insn);
@@ -160,7 +160,7 @@ namespace ir {
BasicBlock::iterator it = pbb->end();
it--;
if((*it).getOpcode() == OP_BRA)
- pbb->erase(it);
+ it->remove();
if(block->getExit()->getNextBlock() == elseblock->getEntry())
return;
@@ -321,8 +321,7 @@ namespace ir {
{
BasicBlock::iterator it= bbs[i]->end();
it--;
-
- bbs[i]->erase(it);
+ it->remove();
if (bbs[i]->hasExtraBra)
bbs[i]->hasExtraBra = false;
--
1.9.1
More information about the Beignet
mailing list