fix bug for dynamic shared memory
This commit is contained in:
parent
ba2c49abdd
commit
3d22cc1f36
|
@ -47,12 +47,9 @@ void mem_share2global(llvm::Module *M) {
|
|||
PointerType::get(array_type->getElementType(), 0);
|
||||
llvm::Constant *x1 = ConstantPointerNull::get(PointerTy);
|
||||
llvm::GlobalVariable *global_ptr = new llvm::GlobalVariable(
|
||||
*M, PointerTy, false, llvm::GlobalValue::CommonLinkage, x1,
|
||||
"wrapper_global_data", NULL,
|
||||
*M, PointerTy, false, llvm::GlobalValue::ExternalLinkage,
|
||||
NULL, "dynamic_shared_memory", NULL,
|
||||
llvm::GlobalValue::GeneralDynamicTLSModel, 0, false);
|
||||
|
||||
global_ptr->setDSOLocal(true);
|
||||
|
||||
corresponding_global_memory.insert(
|
||||
std::pair<GlobalVariable *, GlobalVariable *>(share_memory,
|
||||
global_ptr));
|
||||
|
|
|
@ -234,6 +234,7 @@ void replace_dynamic_shared_memory(llvm::Module *M) {
|
|||
auto new_bit_cast =
|
||||
new BitCastInst(load_shared_memory,
|
||||
dynamic_shared_memory_addr->getType(), "new_bit_cast");
|
||||
new_bit_cast->insertAfter(load_shared_memory);
|
||||
dynamic_shared_memory_addr->replaceUsesWithIf(new_bit_cast, [&](Use &U) {
|
||||
auto *Instr = dyn_cast<Instruction>(U.getUser());
|
||||
return Instr != new_bit_cast && Instr != load_shared_memory;
|
||||
|
|
Loading…
Reference in New Issue