summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/src/llvm/llvm_printf_parser.cpp20
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()));
}