diff options
author | Ruiling Song <ruiling.song@intel.com> | 2014-12-04 14:24:44 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-12-04 14:56:26 +0800 |
commit | c9d3e67158a6635cc757c875f8c793ed52ade1c4 (patch) | |
tree | f055015ecb4f2971261ba18e94fd628ef2c4de7a | |
parent | f034afa6772d21dc1b25b80127b6095a06fcaded (diff) |
GBE: Fix the printf issue caused by new bti implementation
The new bti implementation does not deal with printf internal buffer specially.
Which cause printf print nothing! But I think it is better to declare the
internal buffer for printf in global memory space instead of private space.
Then the bti implementation don't have to deal with it specially.
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r-- | backend/src/llvm/llvm_printf_parser.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp index 11e96332..8fec683d 100644 --- a/backend/src/llvm/llvm_printf_parser.cpp +++ b/backend/src/llvm/llvm_printf_parser.cpp @@ -617,13 +617,25 @@ error: if (!pbuf_ptr) { /* alloc a new buffer ptr to collect the print output. */ - Type *ptrTy = Type::getInt32PtrTy(module->getContext()); - llvm::Constant * pBuf = module->getOrInsertGlobal(StringRef("__gen_ocl_printf_buf"), ptrTy); + Type *ptrTy = Type::getInt32PtrTy(module->getContext(), 1); + llvm::Constant *pBuf = new GlobalVariable(*module, ptrTy, false, + GlobalVariable::ExternalLinkage, + nullptr, + StringRef("__gen_ocl_printf_buf"), + nullptr, + GlobalVariable::NotThreadLocal, + 1); pbuf_ptr = builder->CreatePtrToInt(pBuf, Type::getInt32Ty(module->getContext())); } if (!index_buf_ptr) { - Type *ptrTy = Type::getInt32PtrTy(module->getContext()); - llvm::Constant * pBuf = module->getOrInsertGlobal(StringRef("__gen_ocl_printf_index_buf"), ptrTy); + Type *ptrTy = Type::getInt32PtrTy(module->getContext(), 1); + llvm::Constant *pBuf = new GlobalVariable(*module, ptrTy, false, + GlobalVariable::ExternalLinkage, + nullptr, + StringRef("__gen_ocl_printf_index_buf"), + nullptr, + GlobalVariable::NotThreadLocal, + 1); index_buf_ptr = builder->CreatePtrToInt(pBuf, Type::getInt32Ty(module->getContext())); } |