Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use of old context-based constructor. #372

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/interop/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Create an LLVM function, given its return type `rettyp` and a vector of argument
`argtyp`. The function is marked for inlining, to be embedded in the caller's body.
Returns both the newly created function, and its type.
"""
function create_function(rettyp::LLVMType=LLVM.VoidType(Context()),
function create_function(rettyp::LLVMType=LLVM.VoidType(),
argtyp::Vector{<:LLVMType}=LLVMType[],
name::String="entry")
mod = LLVM.Module("llvmcall")
Expand Down
43 changes: 39 additions & 4 deletions test/interop_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,43 @@ end

@testset "base" begin

@generated function add_one(i)
@generated function foo()
@dispose ctx=Context() begin
f, ft = create_function()

@dispose builder=IRBuilder() begin
entry = BasicBlock(f, "entry")
position!(builder, entry)

ret!(builder)
end

call_function(f, Nothing, Tuple{})
end
end
@test foo() === nothing

@generated function bar()
@dispose ctx=Context() begin
T_int = convert(LLVMType, Int)

f, ft = create_function(T_int)

@dispose builder=IRBuilder() begin
entry = BasicBlock(f, "entry")
position!(builder, entry)

val = ConstantInt(T_int, 42)

ret!(builder, val)
end

call_function(f, Int, Tuple{})
end
end
@test bar() == 42

@generated function baz(i)
@dispose ctx=Context() begin
T_int = convert(LLVMType, Int)

Expand All @@ -21,16 +57,15 @@ end
entry = BasicBlock(f, "entry")
position!(builder, entry)

val = add!(builder, parameters(f)[1], ConstantInt(T_int, 1))
val = add!(builder, parameters(f)[1], ConstantInt(T_int, 42))

ret!(builder, val)
end

call_function(f, Int, Tuple{Int}, :i)
end
end

@test add_one(1) == 2
@test baz(1) == 43

@eval struct GhostType end
@eval struct NonGhostType1
Expand Down
Loading