From 0d929e5d2587d2b54656172f0e50f906a50ffa71 Mon Sep 17 00:00:00 2001 From: foreman Date: Wed, 29 Jul 2015 14:52:10 -0400 Subject: [PATCH] P4 to Git Change 1175237 by mbareghe@mbareghe_stg_win30 on 2015/07/29 14:41:02 EPR #419362 - Forum [170348]: problem with printf for OpenCL 2.0 kernel build - added a set of missing symbols to flex including space, added a extra backslash to escape sequences that could not be handled by flex and also to colon which is defined in flex as a delimiter! Affected files ... ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/MDParser/AMDILMDParser.l#3 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/MDParser/AMDILMDParser.output#2 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/MDParser/lex.yy.cpp#4 edit ... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILProducePrintfMetadata.cpp#6 edit ... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Transforms/Scalar/AMDPrintfRuntimeBinding.cpp#10 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#290 edit ... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/compiler/OCLPrintSpecialChars.cpp#1 add ... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/compiler/OCLPrintSpecialChars.h#1 add ... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/compiler/TestList.cpp#41 edit ... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/compiler/build/Makefile.compiler#44 edit --- rocclr/runtime/device/gpu/gpukernel.cpp | 46 ++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/rocclr/runtime/device/gpu/gpukernel.cpp b/rocclr/runtime/device/gpu/gpukernel.cpp index c68008e3ad..e705ce33b4 100644 --- a/rocclr/runtime/device/gpu/gpukernel.cpp +++ b/rocclr/runtime/device/gpu/gpukernel.cpp @@ -3512,7 +3512,51 @@ HSAILKernel::initPrintf(const aclPrintfFmt* aclPrintf) if (printf_.size() <= index) { printf_.resize(index + 1); } - info.fmtString_ = aclPrintf->fmtStr; + std::string pfmt = aclPrintf->fmtStr; + size_t pos = 0; + for (size_t i = 0; i < pfmt.size(); ++i) { + char symbol = pfmt[pos++]; + if (symbol == '\\') { + // Rest of the C escape sequences (e.g. \') are handled correctly + // by the MDParser, we are not sure exactly how! + switch (pfmt[pos]) { + case 'a': + pos++; + symbol = '\a'; + break; + case 'b': + pos++; + symbol = '\b'; + break; + case 'f': + pos++; + symbol = '\f'; + break; + case 'n': + pos++; + symbol = '\n'; + break; + case 'r': + pos++; + symbol = '\r'; + break; + case 'v': + pos++; + symbol = '\v'; + break; + case '7': + if (pfmt[++pos] == '2') { + pos++; + i++; + symbol = '\72'; + } + break; + default: + break; + } + } + info.fmtString_.push_back(symbol); + } info.fmtString_ += "\n"; uint32_t *tmp_ptr = const_cast(aclPrintf->argSizes); for (uint i = 0; i < aclPrintf->numSizes; i++ , tmp_ptr++) {