@@ -3044,6 +3044,8 @@ function inlining_pass(e::Expr, sv, linfo)
3044
3044
if is (f, _apply)
3045
3045
na = length (e. args)
3046
3046
newargs = Vector {Any} (na- 2 )
3047
+ newstmts = Any[]
3048
+ effect_free_upto = 0
3047
3049
for i = 3 : na
3048
3050
aarg = e. args[i]
3049
3051
t = widenconst (exprtype (aarg, linfo))
@@ -3054,13 +3056,25 @@ function inlining_pass(e::Expr, sv, linfo)
3054
3056
newargs[i- 2 ] = Any[ QuoteNode (x) for x in aarg ]
3055
3057
elseif isa (t, DataType) && t. name === Tuple. name && ! isvatuple (t) &&
3056
3058
length (t. parameters) <= MAX_TUPLE_SPLAT
3059
+ for k = (effect_free_upto+ 1 ): (i- 3 )
3060
+ as = newargs[k]
3061
+ for kk = 1 : length (as)
3062
+ ak = as[kk]
3063
+ if ! effect_free (ak, linfo, true )
3064
+ tmpv = newvar! (sv, widenconst (exprtype (ak, linfo)))
3065
+ push! (newstmts, Expr (:(= ), tmpv, ak))
3066
+ as[kk] = tmpv
3067
+ end
3068
+ end
3069
+ end
3070
+ effect_free_upto = i- 3
3057
3071
if effect_free (aarg, linfo, true )
3058
3072
# apply(f,t::(x,y)) => f(t[1],t[2])
3059
3073
tmpv = aarg
3060
3074
else
3061
3075
# apply(f,t::(x,y)) => tmp=t; f(tmp[1],tmp[2])
3062
3076
tmpv = newvar! (sv, t)
3063
- push! (stmts , Expr (:(= ), tmpv, aarg))
3077
+ push! (newstmts , Expr (:(= ), tmpv, aarg))
3064
3078
end
3065
3079
tp = t. parameters
3066
3080
newargs[i- 2 ] = Any[ mk_getfield (tmpv,j,tp[j]) for j= 1 : length (tp) ]
@@ -3069,6 +3083,7 @@ function inlining_pass(e::Expr, sv, linfo)
3069
3083
return (e,stmts)
3070
3084
end
3071
3085
end
3086
+ append! (stmts, newstmts)
3072
3087
e. args = [Any[e. args[2 ]]; newargs... ]
3073
3088
3074
3089
# now try to inline the simplified call
0 commit comments