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

Replace unsafe assume calls with @assert #31

Merged
merged 1 commit into from
Mar 13, 2024
Merged
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
27 changes: 1 addition & 26 deletions src/FunctionWrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,6 @@ __precompile__(true)

module FunctionWrappers

# Used to bypass NULL check
if VERSION >= v"1.6.0-DEV.663"
@inline function assume(v::Bool)
Base.llvmcall(
("""
declare void @llvm.assume(i1)
define void @fw_assume(i8)
{
%v = trunc i8 %0 to i1
call void @llvm.assume(i1 %v)
ret void
}
""", "fw_assume"), Cvoid, Tuple{Bool}, v)
end
else
@inline function assume(v::Bool)
Base.llvmcall(("declare void @llvm.assume(i1)",
"""
%v = trunc i8 %0 to i1
call void @llvm.assume(i1 %v)
ret void
"""), Cvoid, Tuple{Bool}, v)
end
end

if VERSION >= v"1.5.0"
Base.@pure pass_by_value(T) = Base.allocatedinline(T)
else
Expand Down Expand Up @@ -131,8 +106,8 @@ end
if ptr == C_NULL
# For precompile support
ptr = reinit_wrapper(f)
@assert ptr != C_NULL
end
assume(ptr != C_NULL)
objptr = f.objptr
ccall(ptr, $(map_rettype(Ret)),
(Ptr{Cvoid}, $((map_argtype(Arg) for Arg in Args.parameters)...)),
Expand Down