@@ -118,7 +118,7 @@ Base.:(+)(x::Integer, y::DevicePtr) = y + x
118
118
T_int = convert (LLVMType, Int)
119
119
T_ptr = convert (LLVMType, DevicePtr{T,A})
120
120
121
- T_actual_ptr = LLVM. PointerType (eltyp)
121
+ T_actual_ptr = LLVM. PointerType (eltyp, convert (Int, A) )
122
122
123
123
# create a function
124
124
param_types = [T_ptr, T_int]
@@ -130,10 +130,8 @@ Base.:(+)(x::Integer, y::DevicePtr) = y + x
130
130
position! (builder, entry)
131
131
132
132
ptr = inttoptr! (builder, parameters (llvm_f)[1 ], T_actual_ptr)
133
-
134
133
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)
137
135
138
136
if A != AS. Generic
139
137
metadata (ld)[LLVM. MD_tbaa] = tbaa_addrspace (A)
153
151
T_int = convert (LLVMType, Int)
154
152
T_ptr = convert (LLVMType, DevicePtr{T,A})
155
153
156
- T_actual_ptr = LLVM. PointerType (eltyp)
154
+ T_actual_ptr = LLVM. PointerType (eltyp, convert (Int, A) )
157
155
158
156
# create a function
159
157
param_types = [T_ptr, eltyp, T_int]
165
163
position! (builder, entry)
166
164
167
165
ptr = inttoptr! (builder, parameters (llvm_f)[1 ], T_actual_ptr)
168
-
169
166
ptr = gep! (builder, ptr, [parameters (llvm_f)[3 ]])
170
- ptr_with_as = addrspacecast! (builder, ptr, LLVM. PointerType (eltyp, convert (Int, A)))
171
167
val = parameters (llvm_f)[2 ]
172
- st = store! (builder, val, ptr_with_as )
168
+ st = store! (builder, val, ptr )
173
169
174
170
if A != AS. Generic
175
171
metadata (st)[LLVM. MD_tbaa] = tbaa_addrspace (A)
@@ -201,8 +197,7 @@ const LDGTypes = Union{UInt8, UInt16, UInt32, UInt64,
201
197
T_int32 = LLVM. Int32Type (JuliaContext ())
202
198
T_ptr = convert (LLVMType, DevicePtr{T,AS. Global})
203
199
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))
206
201
207
202
# create a function
208
203
param_types = [T_ptr, T_int]
@@ -222,7 +217,7 @@ const LDGTypes = Union{UInt8, UInt16, UInt32, UInt64,
222
217
" llvm.nvvm.ldg.global.$class .$typ .p1$typ "
223
218
end
224
219
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])
226
221
intrinsic = LLVM. Function (mod, intrinsic_name, intrinsic_typ)
227
222
228
223
# generate IR
@@ -231,11 +226,9 @@ const LDGTypes = Union{UInt8, UInt16, UInt32, UInt64,
231
226
position! (builder, entry)
232
227
233
228
ptr = inttoptr! (builder, parameters (llvm_f)[1 ], T_actual_ptr)
234
-
235
229
ptr = gep! (builder, ptr, [parameters (llvm_f)[2 ]])
236
- ptr_with_as = addrspacecast! (builder, ptr, T_actual_ptr_as)
237
230
ld = call! (builder, intrinsic,
238
- [ptr_with_as , ConstantInt (Int32 (align), JuliaContext ())])
231
+ [ptr , ConstantInt (Int32 (align), JuliaContext ())])
239
232
240
233
metadata (ld)[LLVM. MD_tbaa] = tbaa_addrspace (AS. Global)
241
234
0 commit comments