From a5f976ffce6c604f1c76a5fda8755378fbfc1ded Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sat, 26 Jul 2008 15:00:57 +0200 Subject: [PATCH] Start a new basic block after a continue statement. Fixes bug_d_irstate_244_A/b. --- gen/statements.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gen/statements.cpp b/gen/statements.cpp index 24395c9d..ba758bb9 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -446,14 +446,16 @@ void ContinueStatement::toIR(IRState* p) 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 @@ void ContinueStatement::toIR(IRState* p) 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); } //////////////////////////////////////////////////////////////////////////////