Provide mask at block entry for switch statements.

This fixes a crash if 'cbreak' was used in a 'switch'.  Renamed
FunctionEmitContext::SetLoopMask() to SetBlockEntryMask(), and
similarly the loopMask member variable.
This commit is contained in:
Matt Pharr
2012-07-06 11:08:05 -07:00
parent ac421f68e2
commit 73afab464f
3 changed files with 43 additions and 40 deletions

View File

@@ -830,7 +830,7 @@ void DoStmt::EmitCode(FunctionEmitContext *ctx) const {
// And now emit code for the loop body
ctx->SetCurrentBasicBlock(bloop);
ctx->SetLoopMask(ctx->GetInternalMask());
ctx->SetBlockEntryMask(ctx->GetInternalMask());
ctx->SetDebugPos(pos);
// FIXME: in the StmtList::EmitCode() method takes starts/stops a new
// scope around the statements in the list. So if the body is just a
@@ -1047,7 +1047,7 @@ ForStmt::EmitCode(FunctionEmitContext *ctx) const {
// On to emitting the code for the loop body.
ctx->SetCurrentBasicBlock(bloop);
ctx->SetLoopMask(ctx->GetInternalMask());
ctx->SetBlockEntryMask(ctx->GetInternalMask());
ctx->AddInstrumentationPoint("for loop body");
if (!dynamic_cast<StmtList *>(stmts))
ctx->StartScope();
@@ -2557,6 +2557,7 @@ SwitchStmt::EmitCode(FunctionEmitContext *ctx) const {
bool isUniformCF = (type->IsUniformType() &&
lHasVaryingBreakOrContinue(stmts) == false);
ctx->StartSwitch(isUniformCF, bbDone);
ctx->SetBlockEntryMask(ctx->GetInternalMask());
ctx->SwitchInst(exprValue, svi.defaultBlock ? svi.defaultBlock : bbDone,
svi.caseBlocks, svi.nextBlock);