@@ -227,18 +227,20 @@ end
227
227
bitcast! (builder, arg, actual_typ)
228
228
end
229
229
elseif argtyp <: Ptr
230
- # passed as i64
231
230
T = eltype (argtyp)
232
231
actual_typ = LLVM. PointerType (convert (LLVMType, T))
233
232
actual_arg = if const_arg == C_NULL
234
233
LLVM. PointerNull (actual_typ)
235
234
elseif const_arg != = nothing
236
235
intptr = LLVM. ConstantInt (LLVM. Int64Type (), Int (const_arg))
237
236
const_inttoptr (intptr, actual_typ)
237
+ elseif value_type (arg) isa LLVM. PointerType
238
+ # passed as i8* or ptr
239
+ bitcast! (builder, arg, actual_typ)
238
240
else
241
+ # passed as i64
239
242
inttoptr! (builder, arg, actual_typ)
240
243
end
241
- actual_arg = inttoptr! (builder, arg, actual_typ)
242
244
elseif argtyp <: Bool
243
245
# passed as i8
244
246
T = eltype (argtyp)
287
289
rv = if rettyp <: LLVMPtr
288
290
bitcast! (builder, rv, T_ret)
289
291
elseif rettyp <: Ptr
290
- ptrtoint! (builder, rv, T_ret)
292
+ if T_ret isa LLVM. PointerType
293
+ bitcast! (builder, rv, T_ret)
294
+ else
295
+ ptrtoint! (builder, rv, T_ret)
296
+ end
291
297
elseif rettyp <: Bool
292
298
zext! (builder, rv, T_ret)
293
299
else
@@ -314,6 +320,11 @@ Perform a `ccall` while more accurately preserving argument types like LLVM expe
314
320
315
321
These features can be useful to call LLVM intrinsics, which may expect a specific set of
316
322
argument types.
323
+
324
+ !!! note
325
+
326
+ This macro is not needed anymore on Julia 1.12, where the `llvmcall` ABI has been
327
+ extended to preserve argument types more accurately.
317
328
"""
318
329
macro typed_ccall (intrinsic, cc, rettyp, argtyps, args... )
319
330
# destructure and validate the arguments
0 commit comments