Skip to content

Commit 053d259

Browse files
authored
Handle non-integer pointer types. (#396)
Julia 1.12 will change how these are emitted.
1 parent 5e0b669 commit 053d259

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112

113113
# fetching builds from Buildkite
114114
assert_test:
115-
name: Julia-master ${{ matrix.build }} ${{ matrix.llvm_args }}
115+
name: Julia ${{ matrix.branch }} ${{ matrix.llvm_args }} - ${{ matrix.build }}
116116
runs-on: ${{ matrix.os }}
117117
strategy:
118118
fail-fast: false
@@ -121,14 +121,12 @@ jobs:
121121
arch: [x64]
122122
llvm_args: ['', '--opaque-pointers']
123123
include:
124-
- version: '1.11'
124+
- branch: 'release-1.11'
125125
pipeline: 'julia-release-1-dot-11'
126126
build: 'x86_64-linux-gnuassert'
127-
branch: 'release-1.11'
128-
#- version: 'master'
129-
# pipeline: 'julia-master'
130-
# build: 'x86_64-linux-gnuassert'
131-
# branch: 'master'
127+
- branch: 'master'
128+
pipeline: 'julia-master'
129+
build: 'x86_64-linux-gnuassert'
132130
steps:
133131
- uses: actions/checkout@v4
134132
with:

src/interop/pointer.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,20 @@ end
227227
bitcast!(builder, arg, actual_typ)
228228
end
229229
elseif argtyp <: Ptr
230-
# passed as i64
231230
T = eltype(argtyp)
232231
actual_typ = LLVM.PointerType(convert(LLVMType, T))
233232
actual_arg = if const_arg == C_NULL
234233
LLVM.PointerNull(actual_typ)
235234
elseif const_arg !== nothing
236235
intptr = LLVM.ConstantInt(LLVM.Int64Type(), Int(const_arg))
237236
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)
238240
else
241+
# passed as i64
239242
inttoptr!(builder, arg, actual_typ)
240243
end
241-
actual_arg = inttoptr!(builder, arg, actual_typ)
242244
elseif argtyp <: Bool
243245
# passed as i8
244246
T = eltype(argtyp)
@@ -287,7 +289,11 @@ end
287289
rv = if rettyp <: LLVMPtr
288290
bitcast!(builder, rv, T_ret)
289291
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
291297
elseif rettyp <: Bool
292298
zext!(builder, rv, T_ret)
293299
else
@@ -314,6 +320,11 @@ Perform a `ccall` while more accurately preserving argument types like LLVM expe
314320
315321
These features can be useful to call LLVM intrinsics, which may expect a specific set of
316322
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.
317328
"""
318329
macro typed_ccall(intrinsic, cc, rettyp, argtyps, args...)
319330
# destructure and validate the arguments

0 commit comments

Comments
 (0)