@@ -378,19 +378,21 @@ isType(t::ANY) = isa(t, DataType) && (t::DataType).name === _Type_name
378
378
# true if Type is inlineable as constant (is a singleton)
379
379
isconstType (t:: ANY ) = isType (t) && (isleaftype (t. parameters[1 ]) || t. parameters[1 ] === Union{})
380
380
381
+ iskindtype (t:: ANY ) = (t === DataType || t === UnionAll || t === Union || t === typeof (Bottom))
382
+
381
383
const IInf = typemax (Int) # integer infinity
382
- const n_ifunc = reinterpret (Int32,arraylen)+ 1
383
- const t_ifunc = Array {Tuple{Int,Int,Any},1} (n_ifunc)
384
- const t_ifunc_cost = Array {Int,1} (n_ifunc)
385
- const t_ffunc_key = Array {Function, 1} (0 )
386
- const t_ffunc_val = Array {Tuple{Int,Int,Any},1} (0 )
387
- const t_ffunc_cost = Array {Int,1} (0 )
384
+ const n_ifunc = reinterpret (Int32, arraylen) + 1
385
+ const t_ifunc = Array {Tuple{Int, Int, Any}, 1} (n_ifunc)
386
+ const t_ifunc_cost = Array {Int, 1} (n_ifunc)
387
+ const t_ffunc_key = Array {Any, 1} (0 )
388
+ const t_ffunc_val = Array {Tuple{Int, Int, Any}, 1} (0 )
389
+ const t_ffunc_cost = Array {Int, 1} (0 )
388
390
function add_tfunc (f:: IntrinsicFunction , minarg:: Int , maxarg:: Int , tfunc:: ANY , cost:: Int )
389
- idx = reinterpret (Int32,f) + 1
391
+ idx = reinterpret (Int32, f) + 1
390
392
t_ifunc[idx] = (minarg, maxarg, tfunc)
391
393
t_ifunc_cost[idx] = cost
392
394
end
393
- function add_tfunc (f:: Function , minarg:: Int , maxarg:: Int , tfunc:: ANY , cost:: Int )
395
+ function add_tfunc (#= @nospecialize::Builtin =# f:: Function , minarg:: Int , maxarg:: Int , tfunc:: ANY , cost:: Int )
394
396
push! (t_ffunc_key, f)
395
397
push! (t_ffunc_val, (minarg, maxarg, tfunc))
396
398
push! (t_ffunc_cost, cost)
@@ -711,7 +713,7 @@ add_tfunc(isa, 2, 2,
711
713
if t != = Any && ! has_free_typevars (t)
712
714
if v ⊑ t
713
715
return Const (true )
714
- elseif isa (v, Const) || isa (v, Conditional) || isleaftype (v)
716
+ elseif isa (v, Const) || isa (v, Conditional) || ( isleaftype (v) && ! iskindtype (v) )
715
717
return Const (false )
716
718
end
717
719
end
@@ -1501,20 +1503,20 @@ function builtin_tfunction(f::ANY, argtypes::Array{Any,1},
1501
1503
end
1502
1504
if isa (f, IntrinsicFunction)
1503
1505
iidx = Int (reinterpret (Int32, f:: IntrinsicFunction )) + 1
1504
- if ! isassigned (t_ifunc, iidx)
1505
- # unknown/unhandled intrinsic (most fall in this category since most return an unboxed value)
1506
+ if iidx < 0 || iidx > length (t_ifunc )
1507
+ # invalid intrinsic
1506
1508
return Any
1507
1509
end
1508
1510
tf = t_ifunc[iidx]
1509
1511
else
1510
- fidx = findfirst (t_ffunc_key, f:: Function )
1512
+ fidx = findfirst (t_ffunc_key, f)
1511
1513
if fidx == 0
1512
- # unknown/unhandled builtin or anonymous function
1514
+ # unknown/unhandled builtin function
1513
1515
return Any
1514
1516
end
1515
1517
tf = t_ffunc_val[fidx]
1516
1518
end
1517
- tf = tf:: Tuple{Real, Real , Any}
1519
+ tf = tf:: Tuple{Int, Int , Any}
1518
1520
if ! (tf[1 ] <= length (argtypes) <= tf[2 ])
1519
1521
# wrong # of args
1520
1522
return Bottom
@@ -4640,7 +4642,7 @@ function statement_cost(ex::Expr, src::CodeInfo, mod::Module, params::InferenceP
4640
4642
elseif f == Main. Core. arrayref
4641
4643
return plus_saturate (argcost, isknowntype (ex. typ) ? 4 : params. inline_nonleaf_penalty)
4642
4644
end
4643
- fidx = findfirst (t_ffunc_key, f:: Function )
4645
+ fidx = findfirst (t_ffunc_key, f)
4644
4646
if fidx == 0
4645
4647
# unknown/unhandled builtin or anonymous function
4646
4648
# Use the generic cost of a direct function call
@@ -5906,6 +5908,8 @@ let fs = Any[typeinf_ext, typeinf, typeinf_edge, occurs_outside_getfield, pure_e
5906
5908
if isassigned (t_ifunc, i)
5907
5909
x = t_ifunc[i]
5908
5910
push! (fs, x[3 ])
5911
+ else
5912
+ println (STDERR, " WARNING: tfunc missing for " , reinterpret (IntrinsicFunction, Int32 (i)))
5909
5913
end
5910
5914
end
5911
5915
for f in fs
0 commit comments