Handle "initializer outlining" for loop rewrites in 2.064.

This commit is contained in:
David Nadlinger
2013-10-20 00:22:44 +02:00
committed by Kai Nacke
parent cb341586e3
commit 1d142129e3

View File

@@ -446,7 +446,16 @@ void ForStatement::toIR(IRState* p)
assert(!gIR->scopereturned());
llvm::BranchInst::Create(forbb, gIR->scopebb());
p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,forincbb,endbb));
// In case of loops that have been rewritten to a composite statement
// containing the initializers and then the actual loop, we need to
// register the former as target scope start.
Statement* scopeStart = getRelatedLabeled();
while (ScopeStatement* scope = scopeStart->isScopeStatement())
{
scopeStart = scope->statement;
}
p->func()->gen->targetScopes.push_back(IRTargetScope(
scopeStart, NULL, forincbb, endbb));
// replace current scope
gIR->scope() = IRScope(forbb,forbodybb);