changeset 395:71a40b62b408

Start a new basic block after a continue statement. Fixes bug_d_irstate_244_A/b.
author Christian Kamm <kamm incasoftware de>
date Sat, 26 Jul 2008 15:00:57 +0200
parents 1d351cd26a5a
children b0feb180ce55
files gen/statements.cpp
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gen/statements.cpp	Fri Jul 25 00:39:24 2008 +0200
+++ b/gen/statements.cpp	Sat Jul 26 15:00:57 2008 +0200
@@ -446,14 +446,16 @@
             targetLoopStatement = tmp->statement;
 
         // find the right continue block and jump there
+        bool found = false;
         IRState::LoopScopeVec::reverse_iterator it;
         for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) {
             if(it->s == targetLoopStatement) {
                 llvm::BranchInst::Create(it->begin, gIR->scopebb());
-                return;
+                found = true;
+                break;
             }
         }
-        assert(0);
+        assert(found);
     }
     else {
         // can't 'continue' within switch, so omit them
@@ -466,6 +468,11 @@
         DtoEnclosingHandlers(enclosinghandler, it->enclosinghandler);
         llvm::BranchInst::Create(it->begin, gIR->scopebb());
     }
+
+    // the continue terminated this basicblock, start a new one
+    llvm::BasicBlock* oldend = gIR->scopeend();
+    llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftercontinue", p->topfunc(), oldend);
+    p->scope() = IRScope(bb,oldend);
 }
 
 //////////////////////////////////////////////////////////////////////////////