Skip to content

Commit 836173b

Browse files
committed
Clone linkage and isvararg.
1 parent 8d5022f commit 836173b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/utils.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,21 @@ function clone(f::Function; value_map::Dict{Value,Value}=Dict{Value,Value}())
4141
argtypes = LLVMType[]
4242

4343
# The user might be deleting arguments to the function by specifying them in
44-
# the VMap. If so, we need to not add the arguments to the arg ty vector
44+
# the VMap. If so, we need to not add the arguments to the arg ty vector
4545
for arg in parameters(f)
4646
if !in(arg, keys(value_map)) # Haven't mapped the argument to anything yet?
4747
push!(argtypes, llvmtype(arg))
4848
end
4949
end
5050

5151
# Create a new function type...
52-
fty = FunctionType(return_type(eltype(llvmtype(f))), argtypes) # TODO: isVarArg
52+
vararg = isvararg(eltype(llvmtype(f)))
53+
fty = FunctionType(return_type(eltype(llvmtype(f))), argtypes; vararg)
5354

5455
# Create the new function...
5556
new_f = Function(parent(f), name(f), fty)
56-
# TODO: address space, linkage
57+
linkage!(new_f, linkage(f))
58+
# TODO: address space
5759

5860
# Loop over the arguments, copying the names of the mapped arguments over...
5961
for (arg, new_arg) in zip(parameters(f), parameters(new_f))

test/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
# we always need to map all arguments
6161
value_map = Dict{LLVM.Value, LLVM.Value}(
6262
old_param => new_param for (old_param, new_param) in
63-
zip(parameters(f), parameters(new_f)))
63+
zip(parameters(f), parameters(new_f)))
6464

6565
function type_mapper(typ)
6666
if typ == LLVM.Int32Type(ctx)

0 commit comments

Comments
 (0)