diff --git a/src/compiler/validation.jl b/src/compiler/validation.jl index ce1d2efabd..2c83ebd4a5 100644 --- a/src/compiler/validation.jl +++ b/src/compiler/validation.jl @@ -140,6 +140,21 @@ import GPUCompiler: IRError, InvalidIRError function restore_lookups(mod::LLVM.Module)::Nothing T_size_t = convert(LLVM.LLVMType, Int) + for (v, k) in FFI.ptr_map + if haskey(functions(mod), k) + f = functions(mod)[k] + replace_uses!( + f, + LLVM.Value( + LLVM.API.LLVMConstIntToPtr( + ConstantInt(T_size_t, convert(UInt, v)), + value_type(f), + ), + ), + ) + eraseInst(mod, f) + end + end for f in functions(mod) for fattr in collect(function_attributes(f)) if isa(fattr, LLVM.StringAttribute)