Skip to content

Commit 79d33b2

Browse files
authored
Merge pull request #162 from maleadt/tb/fixes
Small fixes.
2 parents 1e7a8df + 82863ad commit 79d33b2

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/LLVM.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ include("base.jl")
9191

9292
module API
9393
using CEnum
94-
using LLVM
95-
using LLVM: @apicall, libllvm_version
94+
using ..LLVM
95+
using ..LLVM: @apicall, libllvm_version
9696
const off_t = Csize_t
9797
libdir = joinpath(@__DIR__, "..", "lib", LLVM.llvmjl_wrapper)
9898
include(joinpath(libdir, "libLLVM_common.jl"))

src/core/value/constant.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ identify(::Type{Value}, ::Val{API.LLVMUndefValueValueKind}) = UndefValue
1515
UndefValue(typ::LLVMType) = UndefValue(API.LLVMGetUndef(ref(typ)))
1616

1717

18-
@checked struct PointerNull <: User
19-
ref::reftype(User)
20-
end
21-
identify(::Type{Value}, ::Val{API.LLVMConstantPointerNullValueKind}) = PointerNull
22-
23-
PointerNull(typ::PointerType) = PointerNull(API.LLVMConstPointerNull(ref(typ)))
24-
25-
2618
abstract type Constant <: User end
2719

2820
# forward declarations
@@ -32,6 +24,14 @@ end
3224
abstract type Instruction <: User end
3325

3426

27+
@checked struct PointerNull <: Constant
28+
ref::reftype(User)
29+
end
30+
identify(::Type{Value}, ::Val{API.LLVMConstantPointerNullValueKind}) = PointerNull
31+
32+
PointerNull(typ::PointerType) = PointerNull(API.LLVMConstPointerNull(ref(typ)))
33+
34+
3535
## scalar
3636

3737
export ConstantInt, ConstantFP

test/core.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,13 @@ LLVM.Module("SomeModule", ctx) do mod
444444
unsafe_delete!(mod, gv)
445445
@test isempty(gvars)
446446
end
447+
448+
# bug: PointerNull wasn't a constant, and couldn't be used as an initializer
449+
let ptrtyp = LLVM.PointerType(LLVM.VoidType(ctx))
450+
gv = GlobalVariable(mod, ptrtyp, "SomeOtherGlobal")
451+
init = PointerNull(ptrtyp)
452+
initializer!(gv, init)
453+
end
447454
end
448455
end
449456

0 commit comments

Comments
 (0)