summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunyan He <junyan.he@linux.intel.com>2015-12-14 14:51:26 +0800
committerYang Rong <rong.r.yang@intel.com>2015-12-21 11:26:58 +0800
commit032b606f8c5baa53e52b1f55c4f7c0bafdd6ff37 (patch)
tree0e8de1dded7300444d000d89761941a62eb58e33
parent607ff9adc473eaac07c9ad85a12285a84e00a684 (diff)
Backend: Fix a memory leak for structurizer.HEADmaster
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@linux.intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--backend/src/ir/structurizer.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/backend/src/ir/structurizer.cpp b/backend/src/ir/structurizer.cpp
index 38d3dd1c..749cb948 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;