Skip to content

Commit 3a579da

Browse files
authored
Replace unsafe assume calls with @assert (#31)
An `@assert` is enough to convince LLVM to jump-thread this, without the need for unsafe code or llvmcall.
1 parent ad1cea6 commit 3a579da

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

src/FunctionWrappers.jl

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@ __precompile__(true)
44

55
module FunctionWrappers
66

7-
# Used to bypass NULL check
8-
if VERSION >= v"1.6.0-DEV.663"
9-
@inline function assume(v::Bool)
10-
Base.llvmcall(
11-
("""
12-
declare void @llvm.assume(i1)
13-
define void @fw_assume(i8)
14-
{
15-
%v = trunc i8 %0 to i1
16-
call void @llvm.assume(i1 %v)
17-
ret void
18-
}
19-
""", "fw_assume"), Cvoid, Tuple{Bool}, v)
20-
end
21-
else
22-
@inline function assume(v::Bool)
23-
Base.llvmcall(("declare void @llvm.assume(i1)",
24-
"""
25-
%v = trunc i8 %0 to i1
26-
call void @llvm.assume(i1 %v)
27-
ret void
28-
"""), Cvoid, Tuple{Bool}, v)
29-
end
30-
end
31-
327
if VERSION >= v"1.5.0"
338
Base.@pure pass_by_value(T) = Base.allocatedinline(T)
349
else
@@ -131,8 +106,8 @@ end
131106
if ptr == C_NULL
132107
# For precompile support
133108
ptr = reinit_wrapper(f)
109+
@assert ptr != C_NULL
134110
end
135-
assume(ptr != C_NULL)
136111
objptr = f.objptr
137112
ccall(ptr, $(map_rettype(Ret)),
138113
(Ptr{Cvoid}, $((map_argtype(Arg) for Arg in Args.parameters)...)),

0 commit comments

Comments
 (0)