From a65d8b457d7905fb6bbf36bc61c22a1cfaf1db48 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Fri, 11 May 2018 14:22:57 -0400 Subject: [PATCH] Extract PiNode insertion code from #26969 This is just the pinode insertion code from #26969, which together with #27068, should hopefully cover the same benchmarks in a more acceptable way. --- base/compiler/ssair/inlining2.jl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/base/compiler/ssair/inlining2.jl b/base/compiler/ssair/inlining2.jl index 20243203e6f7c..394444cae694f 100644 --- a/base/compiler/ssair/inlining2.jl +++ b/base/compiler/ssair/inlining2.jl @@ -379,11 +379,22 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, topmod::Module, idx: insert_node_here!(compact, GotoIfNot(cond, next_cond_bb), Union{}, line) bb = next_cond_bb - 1 finish_current_bb!(compact) - # Insert Pi nodes here + argexprs′ = argexprs + if !isa(case, ConstantCase) + argexprs′ = copy(argexprs) + for i = 2:length(metharg.parameters) + a, m = atype.parameters[i], metharg.parameters[i] + isa(argexprs[i], SSAValue) || continue + if !(a <: m) + argexprs′[i] = insert_node_here!(compact, PiNode(argexprs′[i], m), + m, line) + end + end + end if isa(case, InliningTodo) - val = ir_inline_item!(compact, idx, argexprs, linetable, case, boundscheck, todo_bbs) + val = ir_inline_item!(compact, idx, argexprs′, linetable, case, boundscheck, todo_bbs) elseif isa(case, MethodInstance) - val = insert_node_here!(compact, Expr(:invoke, case, argexprs...), typ, line) + val = insert_node_here!(compact, Expr(:invoke, case, argexprs′...), typ, line) else case = case::ConstantCase val = case.val