File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,14 @@ export clone_into!, clone
6
6
7
7
type_mapper_callback (typ, type_mapper) =
8
8
Base. unsafe_convert (API. LLVMTypeRef, type_mapper[](LLVMType (typ)))
9
- materializer_callback (val, materializer) =
10
- Base. unsafe_convert (API. LLVMValueRef, materializer[](Value (val)))
9
+ function materializer_callback (val, materializer)
10
+ new_val = materializer[](Value (val))
11
+ if new_val === nothing
12
+ return Base. unsafe_convert (API. LLVMValueRef, C_NULL )
13
+ else
14
+ return Base. unsafe_convert (API. LLVMValueRef, new_val)
15
+ end
16
+ end
11
17
12
18
function clone_into! (new:: Function , old:: Function ;
13
19
value_map:: Dict{Value,Value} = Dict {Value,Value} (),
Original file line number Diff line number Diff line change 14
14
@dispose builder= Builder (ctx) begin
15
15
entry = BasicBlock (f, " entry" ; ctx)
16
16
position! (builder, entry)
17
-
17
+ ptr = const_inttoptr (
18
+ ConstantInt (0xdeadbeef % UInt; ctx),
19
+ LLVM. PointerType (LLVM. Int32Type (ctx)))
18
20
tmp = add! (builder, parameters (f)[1 ], parameters (f)[2 ], " tmp" )
19
- ret! (builder, tmp)
21
+ tmp2 = load! (builder, ptr)
22
+ tmp3 = add! (builder, tmp, tmp2)
23
+ ret! (builder, tmp3)
20
24
21
25
verify (mod)
22
26
end
70
74
end
71
75
end
72
76
function materializer (val)
77
+ if val isa Union{LLVM. ConstantExpr, ConstantInt}
78
+ # test that we can return nothing
79
+ return nothing
80
+ end
73
81
# not needed here
74
- error ()
82
+ error (" " )
75
83
end
76
84
clone_into! (new_f, f; value_map, type_mapper, materializer)
77
85
You can’t perform that action at this time.
0 commit comments