Skip to content

llvmcall with type parameters uses fallback eval method for foreigncall #218

@KristofferC

Description

@KristofferC
function add1234(x::Tuple{T, T, T, T}) where T
    Base.llvmcall("""%3 = extractvalue [4 x i32] %0, 0
      %4 = extractvalue [4 x i32] %0, 1
      %5 = extractvalue [4 x i32] %0, 2
      %6 = extractvalue [4 x i32] %0, 3
      %7 = extractvalue [4 x i32] %1, 0
      %8 = extractvalue [4 x i32] %1, 1
      %9 = extractvalue [4 x i32] %1, 2
      %10 = extractvalue [4 x i32] %1, 3
      %11 = add i32 %3, %7
      %12 = add i32 %4, %8
      %13 = add i32 %5, %9
      %14 = add i32 %6, %10
      %15 = insertvalue [4 x i32] undef, i32 %11, 0
      %16 = insertvalue [4 x i32] %15, i32 %12, 1
      %17 = insertvalue [4 x i32] %16, i32 %13, 2
      %18 = insertvalue [4 x i32] %17, i32 %14, 3
      ret [4 x i32] %18""",Tuple{T,T,T,T},
      Tuple{Tuple{T,T,T,T},Tuple{T,T,T,T}},
        (T(1),T(2),T(3),T(4)),
        x)
end
julia> add1234(map(Int32,(2,3,4,5)))
(3, 5, 7, 9)

julia> @interpret add1234(map(Int32,(2,3,4,5)))
ERROR: MethodError: no method matching sparam_syms(::Module)
Closest candidates are:
  sparam_syms(::Method) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\utils.jl:44
Stacktrace:
 [1] lookup_expr(::Frame, ::Expr) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:24
 [2] macro expansion at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:64 [inlined]
 [3] getargs(::Array{Any,1}, ::Frame) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\builtins-julia1.1.jl:7
 [4] maybe_evaluate_builtin(::Frame, ::Expr, ::Bool) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\builtins-julia1.1.jl:65
 [5] #evaluate_call_compiled!#36(::Bool, ::Function, ::Compiled, ::Frame, ::Expr) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:189
 [6] evaluate_call_compiled! at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:186 [inlined]
 [7] eval_rhs(::Any, ::Frame, ::Expr) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:363
 [8] step_expr!(::Any, ::Frame, ::Any, ::Bool) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:497
 [9] step_expr! at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:536 [inlined] (repeats 2 times)
 [10] optimize!(::Core.CodeInfo, ::Module) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\optimize.jl:172
 [11] #FrameCode#3(::Bool, ::Bool, 

The error is when stepping in the mini-interpreter during optimize!.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions