Skip to content

Commit

Permalink
Preserve the AddrSpacePtr element type in LLVM.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed May 28, 2020
1 parent 60cddd7 commit 7f67ef0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ static Type *bitstype_to_llvm(jl_value_t *bt, bool llvmcall = false)
if (bt == (jl_value_t*)jl_float64_type)
return T_float64;
if (jl_is_addrspace_ptr_type(bt)) {
jl_value_t *ety = jl_tparam0(bt);
jl_value_t *as_param = jl_tparam1(bt);
int as;
if (jl_is_int32(as_param))
Expand All @@ -599,7 +600,7 @@ static Type *bitstype_to_llvm(jl_value_t *bt, bool llvmcall = false)
as = jl_unbox_int64(as_param);
else
jl_error("invalid pointer address space");
return PointerType::get(T_int8, as);
return PointerType::get(bitstype_to_llvm(ety, llvmcall), as);
}
int nb = jl_datatype_size(bt);
return Type::getIntNTy(jl_LLVMContext, nb * 8);
Expand Down
2 changes: 1 addition & 1 deletion test/llvmpasses/llvmcall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ emit(foo, NTuple{2, Float16})
# CHECK: call <2 x half> @foo(<2 x half> %{{[0-9]+}})
emit(foo, NTuple{2, VecElement{Float16}})

# CHECK: call i8 addrspace(3)* @foo(i8 addrspace(3)* %{{[0-9]+}})
# CHECK: call float addrspace(3)* @foo(float addrspace(3)* %{{[0-9]+}})
emit(foo, Core.AddrSpacePtr{Float32, 3})

# CHECK: call { i32, i32 } @foo({ i32, i32 } %{{[0-9]+}})
Expand Down

0 comments on commit 7f67ef0

Please sign in to comment.