From d862672664d10731dc07ba3f30741e2dd043e903 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 21 Dec 2015 20:13:47 +0300 Subject: [PATCH] Fix up return statements in unmasked regions --- stmt.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stmt.cpp b/stmt.cpp index 1ff8979d..4fd0f5f4 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -2972,6 +2972,12 @@ UnmaskedStmt::EmitCode(FunctionEmitContext *ctx) const { stmts->EmitCode(ctx); + + // Do not restore old mask if our basic block is over. This happends if we emit code + // for something like 'unmasked{return;}', for example. + if (ctx->GetCurrentBasicBlock() == NULL) + return; + ctx->SetInternalMask(oldInternalMask); ctx->SetFunctionMask(oldFunctionMask); }