summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunyan He <junyan.he@linux.intel.com>2014-09-01 16:18:45 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-09-05 17:50:59 +0800
commit4c9528e08da8e684fa5b0060a6b3c08507364cfb (patch)
tree7f48874e4b1c6b270dfec16702db1941193d1e19
parent9f7cdc133d659c449707b2a51d3fcd1f99c2b0b2 (diff)
Fix the global string bug for printf.
When there are multi printf statements in multi kernel fucntions within the same translate unit, if they have the same sting parameter, the Clang will just generate one global string named .strXXX to represent that string. So when translating the kernel to gen, we can not unref that global var. Just ignore it to avoid assert. Signed-off-by: Junyan He <junyan.he@linux.intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--backend/src/llvm/llvm_gen_backend.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 39ae3842..09220d64 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -1728,6 +1728,18 @@ namespace gbe
ctx.getFunction().getPrintfSet()->setIndexBufBTI(btiBase);
globalPointer.insert(std::make_pair(&v, btiBase++));
regTranslator.newScalarProxy(ir::ocl::printfiptr, const_cast<GlobalVariable*>(&v));
+ } else if(v.getName().str().substr(0, 4) == ".str") {
+ /* When there are multi printf statements in multi kernel fucntions within the same
+ translate unit, if they have the same sting parameter, such as
+ kernel_func1 () {
+ printf("Line is %d\n", line_num1);
+ }
+ kernel_func2 () {
+ printf("Line is %d\n", line_num2);
+ }
+ The Clang will just generate one global string named .strXXX to represent "Line is %d\n"
+ So when translating the kernel_func1, we can not unref that global var, so we will
+ get here. Just ignore it to avoid assert. */
} else {
GBE_ASSERT(0);
}