Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4804,6 +4804,7 @@ function no_type_setting(@nospecialize(specTypes::Type{<:Tuple}); world = nothin
end

const DumpPreCheck = Ref(false)
const DumpPostCheck = Ref(false)
const DumpPreOpt = Ref(false)

function GPUCompiler.compile_unhooked(output::Symbol, job::CompilerJob{<:EnzymeTarget})
Expand Down Expand Up @@ -4883,6 +4884,9 @@ function GPUCompiler.compile_unhooked(output::Symbol, job::CompilerJob{<:EnzymeT
end
interp = GPUCompiler.get_interpreter(job)
check_ir(interp, job, mod)
if DumpPostCheck[]
API.EnzymeDumpModuleRef(mod.ref)
end

disableFallback = String[]

Expand Down
17 changes: 10 additions & 7 deletions src/compiler/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,8 @@ function check_ir!(interp, @nospecialize(job::CompilerJob), errors::Vector{IRErr
fname = ops[2]

if isa(flib, LLVM.LoadInst)
op, _ = get_base_and_offset(operands(flib)[1]; offsetAllowed=false, inttoptr=true)
op, off = get_base_and_offset(operands(flib)[1]; inttoptr=true)

if isa(op, LLVM.LoadInst)
pop, _ = get_base_and_offset(operands(op)[1]; offsetAllowed=false, inttoptr=true)

Expand All @@ -796,7 +796,7 @@ function check_ir!(interp, @nospecialize(job::CompilerJob), errors::Vector{IRErr

rep = zop
PT = value_type(rep)
if isa(PT, LLVM.PointerType)
if isa(PT, LLVM.PointerType)
rep = LLVM.const_inttoptr(rep, LLVM.PointerType(eltype(PT)))
rep = LLVM.const_addrspacecast(rep, PT)
replace_uses!(pop, rep)
Expand All @@ -808,7 +808,10 @@ function check_ir!(interp, @nospecialize(job::CompilerJob), errors::Vector{IRErr
end

if isa(op, ConstantInt)
rep = reinterpret(Ptr{Cvoid}, convert(Csize_t, op) + 8)
@static if VERSION < v"1.12"
off += 8
end
rep = reinterpret(Ptr{Cvoid}, convert(Csize_t, op) + off)
ld = unsafe_load(convert(Ptr{Ptr{Cvoid}}, rep))
flib = Base.unsafe_pointer_to_objref(ld)
end
Expand All @@ -830,8 +833,8 @@ function check_ir!(interp, @nospecialize(job::CompilerJob), errors::Vector{IRErr
fname = String(map(Base.Fix1(convert, UInt8), collect(fname)[1:(end-1)]))
end

if !isa(fname, String) || !isa(flib, String)
return
if !isa(fname, String) || !isa(flib, String)
return
end

found, replaceWith = try_import_llvmbc(mod, flib, fname, imported)
Expand Down Expand Up @@ -882,7 +885,7 @@ function check_ir!(interp, @nospecialize(job::CompilerJob), errors::Vector{IRErr
fname,
)
end
catch
catch e
nothing
end

Expand Down
Loading