@@ -118,7 +118,7 @@ Base.:(+)(x::Integer, y::DevicePtr) = y + x
118118 T_int = convert (LLVMType, Int)
119119 T_ptr = convert (LLVMType, DevicePtr{T,A})
120120
121- T_actual_ptr = LLVM. PointerType (eltyp)
121+ T_actual_ptr = LLVM. PointerType (eltyp, convert (Int, A) )
122122
123123 # create a function
124124 param_types = [T_ptr, T_int]
@@ -130,10 +130,8 @@ Base.:(+)(x::Integer, y::DevicePtr) = y + x
130130 position! (builder, entry)
131131
132132 ptr = inttoptr! (builder, parameters (llvm_f)[1 ], T_actual_ptr)
133-
134133 ptr = gep! (builder, ptr, [parameters (llvm_f)[2 ]])
135- ptr_with_as = addrspacecast! (builder, ptr, LLVM. PointerType (eltyp, convert (Int, A)))
136- ld = load! (builder, ptr_with_as)
134+ ld = load! (builder, ptr)
137135
138136 if A != AS. Generic
139137 metadata (ld)[LLVM. MD_tbaa] = tbaa_addrspace (A)
153151 T_int = convert (LLVMType, Int)
154152 T_ptr = convert (LLVMType, DevicePtr{T,A})
155153
156- T_actual_ptr = LLVM. PointerType (eltyp)
154+ T_actual_ptr = LLVM. PointerType (eltyp, convert (Int, A) )
157155
158156 # create a function
159157 param_types = [T_ptr, eltyp, T_int]
165163 position! (builder, entry)
166164
167165 ptr = inttoptr! (builder, parameters (llvm_f)[1 ], T_actual_ptr)
168-
169166 ptr = gep! (builder, ptr, [parameters (llvm_f)[3 ]])
170- ptr_with_as = addrspacecast! (builder, ptr, LLVM. PointerType (eltyp, convert (Int, A)))
171167 val = parameters (llvm_f)[2 ]
172- st = store! (builder, val, ptr_with_as )
168+ st = store! (builder, val, ptr )
173169
174170 if A != AS. Generic
175171 metadata (st)[LLVM. MD_tbaa] = tbaa_addrspace (A)
@@ -201,8 +197,7 @@ const LDGTypes = Union{UInt8, UInt16, UInt32, UInt64,
201197 T_int32 = LLVM. Int32Type (JuliaContext ())
202198 T_ptr = convert (LLVMType, DevicePtr{T,AS. Global})
203199
204- T_actual_ptr = LLVM. PointerType (eltyp)
205- T_actual_ptr_as = LLVM. PointerType (eltyp, convert (Int, AS. Global))
200+ T_actual_ptr = LLVM. PointerType (eltyp, convert (Int, AS. Global))
206201
207202 # create a function
208203 param_types = [T_ptr, T_int]
@@ -222,7 +217,7 @@ const LDGTypes = Union{UInt8, UInt16, UInt32, UInt64,
222217 " llvm.nvvm.ldg.global.$class .$typ .p1$typ "
223218 end
224219 mod = LLVM. parent (llvm_f)
225- intrinsic_typ = LLVM. FunctionType (eltyp, [T_actual_ptr_as , T_int32])
220+ intrinsic_typ = LLVM. FunctionType (eltyp, [T_actual_ptr , T_int32])
226221 intrinsic = LLVM. Function (mod, intrinsic_name, intrinsic_typ)
227222
228223 # generate IR
@@ -231,11 +226,9 @@ const LDGTypes = Union{UInt8, UInt16, UInt32, UInt64,
231226 position! (builder, entry)
232227
233228 ptr = inttoptr! (builder, parameters (llvm_f)[1 ], T_actual_ptr)
234-
235229 ptr = gep! (builder, ptr, [parameters (llvm_f)[2 ]])
236- ptr_with_as = addrspacecast! (builder, ptr, T_actual_ptr_as)
237230 ld = call! (builder, intrinsic,
238- [ptr_with_as , ConstantInt (Int32 (align), JuliaContext ())])
231+ [ptr , ConstantInt (Int32 (align), JuliaContext ())])
239232
240233 metadata (ld)[LLVM. MD_tbaa] = tbaa_addrspace (AS. Global)
241234
0 commit comments