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
66
77type_mapper_callback (typ, type_mapper) =
88 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
1117
1218function clone_into! (new:: Function , old:: Function ;
1319 value_map:: Dict{Value,Value} = Dict {Value,Value} (),
Original file line number Diff line number Diff line change 1414 @dispose builder= Builder (ctx) begin
1515 entry = BasicBlock (f, " entry" ; ctx)
1616 position! (builder, entry)
17-
17+ ptr = const_inttoptr (
18+ ConstantInt (0xdeadbeef % UInt; ctx),
19+ LLVM. PointerType (LLVM. Int32Type (ctx)))
1820 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)
2024
2125 verify (mod)
2226 end
7074 end
7175 end
7276 function materializer (val)
77+ if val isa Union{LLVM. ConstantExpr, ConstantInt}
78+ # test that we can return nothing
79+ return nothing
80+ end
7381 # not needed here
74- error ()
82+ error (" " )
7583 end
7684 clone_into! (new_f, f; value_map, type_mapper, materializer)
7785
You can’t perform that action at this time.
0 commit comments