Many thanks for your input. Much appreciated.
I reduced the problem to the following MWE for sparse()
# A MWE for assembly of 1D linear Lagrange shape functions
nelems = 10; h = 1/nelems; nnodes = nelems+1
II = zeros(Int64,4*nelems)
JJ = zeros(Int64,4*nelems)
Avalues = zeros(4*nelems)
for k = 1:nelems
II[4*(k-1)+1:4*k] .= [k, k, k+1, k+1]
JJ[4*(k-1)+1:4*k] .= [k, k+1, k, k+1]
Avalues[4*(k-1)+1:4*k] .= [h, -h, -h, h]
end
@code_warntype sparse(II,JJ,Avalues,nnodes,nnodes,+)
yielding the output with red font. Is this red font output entirely harmless?
MethodInstance for SparseArrays.sparse(::Vector{Int64}, ::Vector{Int64}, ::Vector{Float64}, ::Int64, ::Int64, ::typeof(+))
from sparse(I::AbstractVector{Ti}, J::AbstractVector{Ti}, V::AbstractVector{Tv}, m::Integer, n::Integer, combine) where {Tv, Ti<:Integer} @ SparseArrays ~/.julia/juliaup/julia-1.10.9+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/SparseArrays/src/sparsematrix.jl:1050
Static Parameters
Tv = Float64
Ti = Int64
Arguments
#self#::Core.Const(SparseArrays.sparse)
I::Vector{Int64}
J::Vector{Int64}
V::Vector{Float64}
m::Int64
n::Int64
combine::Core.Const(+)
Locals
cscnzval::Vector{Float64}
cscrowval::Vector{Int64}
klasttouch::Vector{Int64}
csccolptr::Vector{Int64}
csrnzval::Vector{Float64}
csrcolval::Vector{Int64}
csrrowptr::Vector{Int64}
coolen::Int64
Body::SparseMatrixCSC{Float64, Int64}
1 ββ Core.NewvarNode(:(cscnzval))
β Core.NewvarNode(:(cscrowval))
β Core.NewvarNode(:(klasttouch))
β Core.NewvarNode(:(csccolptr))
β Core.NewvarNode(:(csrnzval))
β Core.NewvarNode(:(csrcolval))
β Core.NewvarNode(:(csrrowptr))
β SparseArrays.require_one_based_indexing(I, J, V)
β (coolen = SparseArrays.length(I))
β %10 = SparseArrays.length(J)::Int64
β %11 = (%10 != coolen)::Bool
ββββ goto #3 if not %11
2 ββ goto #4
3 ββ %14 = SparseArrays.length(V)::Int64
β %15 = (%14 != coolen)::Bool
ββββ goto #5 if not %15
4 ββ %17 = SparseArrays.length(I)::Int64
β %18 = SparseArrays.length(J)::Int64
β %19 = Base.string("length(I) (=", %17, ") == length(J) (= ", %18, ") == length(V) (= ")::String
β %20 = SparseArrays.length(V)::Any
β %21 = Base.string(%20, ")")::Any
β %22 = SparseArrays.string("the first three arguments' lengths must match, ", %19, %21)::Any
β %23 = SparseArrays.ArgumentError(%22)::Any
ββββ SparseArrays.throw(%23)
5 ββ %25 = Base.hastypemax::Core.Const(Base.hastypemax)
β %26 = (%25)($(Expr(:static_parameter, 2)))::Core.Const(true)
ββββ goto #8 if not %26
6 ββ %28 = coolen::Int64
β %29 = SparseArrays.typemax($(Expr(:static_parameter, 2)))::Core.Const(9223372036854775807)
β %30 = (%28 >= %29)::Bool
ββββ goto #8 if not %30
7 ββ %32 = Base.string("the index type ", $(Expr(:static_parameter, 2)), " cannot hold ", coolen, " elements; use a larger index type")::Any
β %33 = SparseArrays.ArgumentError(%32)::Any
ββββ SparseArrays.throw(%33)
8 ββ %35 = (m == 0)::Bool
ββββ goto #10 if not %35
9 ββ goto #13
10 β %38 = (n == 0)::Bool
ββββ goto #12 if not %38
11 β goto #13
12 β %41 = (coolen == 0)::Bool
ββββ goto #19 if not %41
13 β %43 = (coolen != 0)::Bool
ββββ goto #18 if not %43
14 β %45 = (n == 0)::Bool
ββββ goto #16 if not %45
15 β %47 = SparseArrays.ArgumentError("column indices J[k] must satisfy 1 <= J[k] <= n")::Any
β SparseArrays.throw(%47)
ββββ Core.Const(:(goto %54))
16 β %50 = (m == 0)::Bool
ββββ goto #18 if not %50
17 β %52 = SparseArrays.ArgumentError("row indices I[k] must satisfy 1 <= I[k] <= m")::Any
ββββ SparseArrays.throw(%52)
18 β %54 = SparseArrays.one($(Expr(:static_parameter, 2)))::Core.Const(1)
β %55 = (n + 1)::Int64
β %56 = SparseArrays.fill(%54, %55)::Vector{Int64}
β %57 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 2)))::Core.Const(Vector{Int64})
β %58 = (%57)()::Vector{Int64}
β %59 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 1)))::Core.Const(Vector{Float64})
β %60 = (%59)()::Vector{Float64}
β %61 = SparseArrays.SparseMatrixCSC(m, n, %56, %58, %60)::SparseMatrixCSC{Float64, Int64}
ββββ return %61
19 β %63 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 2)))::Core.Const(Vector{Int64})
β %64 = SparseArrays.undef::Core.Const(UndefInitializer())
β %65 = (m + 1)::Int64
β (csrrowptr = (%63)(%64, %65))
β %67 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 2)))::Core.Const(Vector{Int64})
β %68 = SparseArrays.undef::Core.Const(UndefInitializer())
β (csrcolval = (%67)(%68, coolen))
β %70 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 1)))::Core.Const(Vector{Float64})
β %71 = SparseArrays.undef::Core.Const(UndefInitializer())
β (csrnzval = (%70)(%71, coolen))
β %73 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 2)))::Core.Const(Vector{Int64})
β %74 = SparseArrays.undef::Core.Const(UndefInitializer())
β %75 = (n + 1)::Int64
β (csccolptr = (%73)(%74, %75))
β %77 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 2)))::Core.Const(Vector{Int64})
β %78 = SparseArrays.undef::Core.Const(UndefInitializer())
β (klasttouch = (%77)(%78, n))
β %80 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 2)))::Core.Const(Vector{Int64})
β (cscrowval = (%80)())
β %82 = Core.apply_type(SparseArrays.Vector, $(Expr(:static_parameter, 1)))::Core.Const(Vector{Float64})
β (cscnzval = (%82)())
β %84 = SparseArrays.sparse!(I, J, V, m, n, combine, klasttouch, csrrowptr, csrcolval, csrnzval, csccolptr, cscrowval, cscnzval)::SparseMatrixCSC{Float64, Int64}
ββββ return %84