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:
5
stmt.cpp
5
stmt.cpp
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user