Commit 9dfc01d1 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Eager-decref the iterable when breaking a loop

parent fa775e2c
......@@ -2423,6 +2423,7 @@ public:
curblock->connectTo(test_false);
CFGBlock* loop_block = cfg->addBlock();
CFGBlock* break_block = cfg->addDeferredBlock();
CFGBlock* end_block = cfg->addDeferredBlock();
CFGBlock* else_block = cfg->addDeferredBlock();
......@@ -2433,8 +2434,7 @@ public:
curblock = test_false;
pushJump(else_block);
// TODO: need to del the iter_name when break'ing out of the loop
pushLoopContinuation(test_block, end_block);
pushLoopContinuation(test_block, break_block);
curblock = loop_block;
InternedString next_name(nodeName());
......@@ -2481,6 +2481,15 @@ public:
if (curblock)
pushJump(end_block);
if (break_block->predecessors.size() == 0) {
delete break_block;
} else {
cfg->placeBlock(break_block);
curblock = break_block;
push_back(makeKill(itername));
pushJump(end_block);
}
if (end_block->predecessors.size() == 0) {
delete end_block;
curblock = NULL;
......
......@@ -32,4 +32,8 @@ def f3():
print i
else:
print -1
for i in MyIterable():
break
print "a"
f3()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment