Signature of Julia llvm function when using arrays

When looking at the LLVM IR that the julia compiler generates (using code_llvm), I noticed something strange in the function signature when using arrays as arguments. Let me give an example:

function test(a,b,c)
    return nothing
end

(This is a useless example, but the results are the same with other functions, the resulting IR of this example is less cluttered)

Using code_llvm(test, (Int,Int,Int)), I get the following output:

; Function Attrs: sspreq
define void @julia_test14855(i64, i64, i64) #2 {
top:
  ret void, !dbg !366
}

Using code_llvm(test, (Array{Int},Array{Int},Array{Int})), I get (at least for me) an unexpected result:

; Function Attrs: sspreq
define %jl_value_t* @julia_test14856(%jl_value_t*, %jl_value_t**, i32) #2 {
top:
  %3 = icmp eq i32 %2, 3, !dbg !369
  br i1 %3, label %ifcont, label %else, !dbg !369

else:                                             ; preds = %top
  call void @jl_error(i8* getelementptr inbounds ([26 x i8]* @_j_str0, i64 0, i64 0)), !dbg !369
  unreachable, !dbg !369

ifcont:                                           ; preds = %top
  %4 = load %jl_value_t** inttoptr (i64 36005472 to %jl_value_t**), align 32, !dbg !370
  ret %jl_value_t* %4, !dbg !370
}

Why doesn't the llvm function signature just list 3 variables like i64*or something like that? And why doesn't the function return voidanymore?

+3
source share
2 answers

Why is the signature of the llvm function not just listing the 3 variables as i64*

(, @ivarne, ).

@julia_test14856(%jl_value_t*, %jl_value_t**, i32) :

  • (jl_value_t - )

@ivarne - . - , ( , ).

( 3 → goto else:):

top:
  %3 = icmp eq i32 %2, 3, !dbg !369
  br i1 %3, label %ifcont, label %else, !dbg !369

:

else:                                             ; preds = %top
  call void @jl_error(i8* getelementptr inbounds ([26 x i8]* @_j_str0, i64 0, i64 0)), !dbg !369
  unreachable, !dbg !369

, , nothing, 36005472 ( @ivarne , void ).

%4 = load %jl_value_t** inttoptr (i64 36005472 to %jl_value_t**), align 32, !dbg !370

+4

, , Array{Int, N} , .

julia> code_llvm(test, (Array{Int,1},Array{Int,1},Array{Int,1}))

define void @julia_test15626(%jl_value_t*, %jl_value_t*, %jl_value_t*) {
top:
  ret void, !dbg !974
}

​​ , .

+2

All Articles