Skip to content

Commit

Permalink
Fix bug in local memory.
Browse files Browse the repository at this point in the history
We return a LLVMPtr, so no need to ptrtoint, but we only need to get rid
of the type (Julia passes LLVMPtr as i8).
  • Loading branch information
maleadt committed Nov 20, 2020
1 parent ebfaa58 commit 25b84b6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/device/opencl/memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ end
@generated function emit_localmemory(::Val{id}, ::Type{T}, ::Val{len}=Val(0)) where {id,T,len}
JuliaContext() do ctx
eltyp = convert(LLVMType, T, ctx)

T_ptr = convert(LLVMType, LLVMPtr{T,AS.Local}, ctx)

# create a function
Expand All @@ -44,11 +43,11 @@ end
entry = BasicBlock(llvm_f, "entry", ctx)
position!(builder, entry)

ptr = gep!(builder, gv, [ConstantInt(0, ctx),
ConstantInt(0, ctx)])
ptr = gep!(builder, gv, [ConstantInt(0, ctx), ConstantInt(0, ctx)])

untyped_ptr = bitcast!(builder, ptr, T_ptr)

val = ptrtoint!(builder, ptr, T_ptr)
ret!(builder, val)
ret!(builder, untyped_ptr)
end

call_function(llvm_f, LLVMPtr{T,AS.Local})
Expand Down

0 comments on commit 25b84b6

Please sign in to comment.