summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorJunyan He <junyan.he@linux.intel.com>2014-09-02 13:49:53 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-09-03 09:49:43 +0800
commit020ac2234141727bd80a01e5e3933ae3b12efd79 (patch)
tree0233aa3729c230ef87d97ad87523c12399cdb314 /backend
parent172bcc7f2abe0dbf72978e53017156bdb7a1722c (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>
Diffstat (limited to 'backend')
-rw-r--r--backend/src/llvm/llvm_gen_backend.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 577564dc..c2c60a80 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -1702,7 +1702,21 @@ namespace gbe
GBE_ASSERT(con.getName() == v.getName());
ctx.LOADI(ir::TYPE_S32, reg, ctx.newIntegerImmediate(con.getOffset(), ir::TYPE_S32));
} else {
- GBE_ASSERT(0);
+ 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);
+ }
}
}