From 89bbceefee52d486dfe60c5f8f6cccac0a6766db Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 25 Mar 2012 10:07:12 -0700 Subject: [PATCH] Make sure that foreach() statements never execute with an "all off" mask. --- ast.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ast.cpp b/ast.cpp index c89f00bb..7f601d04 100644 --- a/ast.cpp +++ b/ast.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2011, Intel Corporation + Copyright (c) 2011-2012, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -32,8 +32,10 @@ */ /** @file ast.cpp - @brief -*/ + + @brief General functionality related to abstract syntax trees and + traversal of them. + */ #include "ast.h" #include "expr.h" @@ -363,6 +365,16 @@ lCheckAllOffSafety(ASTNode *node, void *data) { return false; } + if (dynamic_cast(node) != NULL) { + // foreach() statements also shouldn't be run with an all-off mask. + // Since they re-establish an 'all on' mask, this would be pretty + // unintuitive. (More generally, it's possibly a little strange to + // allow foreach() in the presence of any non-uniform control + // flow...) + *okPtr = false; + return false; + } + if (g->target.allOffMaskIsSafe == true) // Don't worry about memory accesses if we have a target that can // safely run them with the mask all off