diff --git a/base/inference.jl b/base/inference.jl index bcdb0c5c953b2..30a86f4ff9a09 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -1974,17 +1974,6 @@ function exprtype(x::ANY, sv::StaticVarInfo) end end -function without_linenums(a::Array{Any,1}) - l = [] - for x in a - if (isa(x,Expr) && is(x.head,:line)) || isa(x,LineNumberNode) - else - push!(l, x) - end - end - l -end - # known affect-free calls (also effect-free) const _pure_builtins = Any[tuple, svec, fieldtype, apply_type, is, isa, typeof, typeassert] @@ -2032,6 +2021,10 @@ function effect_free(e::ANY, sv, allow_volatile::Bool) isa(e,TopNode) || isa(e,QuoteNode) || isa(e,Type) || isa(e,Tuple) return true end + if isa(e,GlobalRef) + allow_volatile && return true + return isconst(e.mod, e.name) + end if isconstantfunc(e, sv) !== false return true end @@ -2248,7 +2241,8 @@ function inlineable(f::ANY, e::Expr, atype::ANY, sv::StaticVarInfo, enclosing_as end body = Expr(:block) - body.args = without_linenums(ast.args[3].args)::Array{Any,1} + body.args = filter(x->!((isa(x,Expr) && is(x.head,:line)) || isa(x,LineNumberNode)), + ast.args[3].args::Array{Any,1}) cost::Int = 1000 if incompletematch cost *= 4 @@ -2284,6 +2278,9 @@ function inlineable(f::ANY, e::Expr, atype::ANY, sv::StaticVarInfo, enclosing_as return NF end end + # remove empty meta + body.args = filter(x->!(isa(x,Expr) && x.head === :meta && isempty(x.args)), + body.args) spnames = Any[ sp[i].name for i=1:2:length(sp) ] enc_vinflist = enclosing_ast.args[2][1]::Array{Any,1} diff --git a/src/codegen.cpp b/src/codegen.cpp index 82e914afc1300..7231d111e64ef 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1572,7 +1572,7 @@ static void mark_volatile_vars(jl_array_t *stmts, std::map