The PrintfParse::printfs static is not thread safe and maybe reset or adding something wrong when runing in mutlithread. Fix the problem by change the printfs to a thread local variable.
Signed-off-by: Pan Xiuli <[email protected]> --- backend/src/llvm/llvm_printf_parser.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp index bdaed8a..93f87ea 100644 --- a/backend/src/llvm/llvm_printf_parser.cpp +++ b/backend/src/llvm/llvm_printf_parser.cpp @@ -45,6 +45,8 @@ namespace gbe { using namespace ir; + thread_local map<CallInst*, PrintfSet::PrintfFmt*> printfs; + /* Return the conversion_specifier if succeed, -1 if failed. */ static char __parse_printf_state(char *begin, char *end, char** rend, PrintfState * state) { @@ -301,7 +303,6 @@ error: Value* g1Xg2Xg3; Value* wg_offset; int out_buf_sizeof_offset; - static map<CallInst*, PrintfSet::PrintfFmt*> printfs; int printf_num; int totalSizeofSize; @@ -972,12 +973,10 @@ error: return false; } - map<CallInst*, PrintfSet::PrintfFmt*> PrintfParser::printfs; - void* getPrintfInfo(CallInst* inst) { - if (PrintfParser::printfs[inst]) - return (void*)PrintfParser::printfs[inst]; + if (printfs[inst]) + return (void*)printfs[inst]; return NULL; } -- 2.1.4 _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
