From f29ab20190a2b6bd2267f217e69f0844b97ee2e1 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 19 Jul 2018 12:20:43 -0400 Subject: [PATCH] fix inlining cost of IntrinsicFunctions when consts have been widened along with the llvmcall fix, this fixes #28078 --- base/compiler/optimize.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index a1de268c7713b..a2fe0fe5a86bb 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -266,7 +266,16 @@ function statement_cost(ex::Expr, line::Int, src::CodeInfo, spvals::SimpleVector if is_meta_expr_head(head) return 0 elseif head === :call - ftyp = argextype(ex.args[1], src, spvals, slottypes) + farg = ex.args[1] + ftyp = argextype(farg, src, spvals, slottypes) + if ftyp === IntrinsicFunction && farg isa SSAValue + # if this comes from code that was already inlined into another function, + # Consts have been widened. try to recover in simple cases. + farg = src.code[farg.id] + if isa(farg, GlobalRef) || isa(farg, QuoteNode) || isa(farg, IntrinsicFunction) || isexpr(farg, :static_parameter) + ftyp = argextype(farg, src, spvals, slottypes) + end + end f = singleton_type(ftyp) if isa(f, IntrinsicFunction) iidx = Int(reinterpret(Int32, f::IntrinsicFunction)) + 1