@@ -33,20 +33,22 @@ function find_eqs_vars(state::TransformationState)
3333 find_eqs_vars (state. structure. graph, compact)
3434end
3535
36- function ir_add! (compact:: IncrementalCompact , line, settings:: Settings , @nospecialize (_a), @nospecialize (_b))
36+ function ir_add! (compact:: IncrementalCompact , line, settings:: Settings , @nospecialize (_a), @nospecialize (_b), source = nothing )
3737 a, b = _a, _b
3838 (b === nothing || b === 0. ) && return _a
3939 (a === nothing || b === 0. ) && return _b
40- idx = @insert_node_here compact line settings (a + b):: Any
40+ source = @something (source, @__SOURCE__ )
41+ idx = _insert_node_here! (compact, line, settings, source, :($ a + $ b), Any)
4142 compact[idx][:flag ] |= Compiler. IR_FLAG_REFINED
4243 idx
4344end
4445
45- function ir_mul_const! (compact, line, settings, coeff:: Float64 , _a)
46+ function ir_mul_const! (compact, line, settings, coeff:: Float64 , _a, source = nothing )
4647 if isone (coeff)
4748 return _a
4849 end
49- idx = @insert_node_here compact line settings (coeff * _a):: Any
50+ source = @something (source, @__SOURCE__ )
51+ idx = _insert_node_here! (compact, line, settings, source, :($ coeff * $ _a), Any)
5052 compact[idx][:flag ] |= Compiler. IR_FLAG_REFINED
5153 return idx
5254end
6062
6163function schedule_incidence! (compact, curval, incT:: Const , var, line, settings; vars= nothing , schedule_missing_var! = nothing )
6264 if curval != = nothing
63- return (ir_add! (compact, line, settings, curval, incT. val), nothing )
65+ return (ir_add! (compact, line, settings, curval, incT. val, @__SOURCE__ ), nothing )
6466 end
6567 return (incT. val, nothing )
6668end
@@ -93,8 +95,8 @@ function schedule_incidence!(compact, curval, incT::Incidence, var, line, settin
9395 end
9496 end
9597
96- acc = ir_mul_const! (compact, line, settings, coeff, lin_var_ssa)
97- curval = curval === nothing ? acc : ir_add! (compact, line, settings, curval, acc)
98+ acc = ir_mul_const! (compact, line, settings, coeff, lin_var_ssa, @__SOURCE__ )
99+ curval = curval === nothing ? acc : ir_add! (compact, line, settings, curval, acc, @__SOURCE__ )
98100 end
99101 (curval, _) = schedule_incidence! (compact, curval, incT. typ, var, line, settings; vars, schedule_missing_var!)
100102 return (curval, thiscoeff)
@@ -1085,7 +1087,7 @@ function tearing_schedule!(state::TransformationState, ci::CodeInstance, key::To
10851087 this_nonlinearssa = SSAValue (eqcallssa. id)
10861088 line = compact1[eqcallssa][:line ]
10871089 end
1088- nonlinearssa = nonlinearssa === nothing ? this_nonlinearssa : ir_add! (compact1, line, settings, this_nonlinearssa, nonlinearssa)
1090+ nonlinearssa = nonlinearssa === nothing ? this_nonlinearssa : ir_add! (compact1, line, settings, this_nonlinearssa, nonlinearssa, @__SOURCE__ )
10891091 end
10901092 mapping = result. eq_callee_mapping[eq]
10911093 if mapping != = nothing
@@ -1113,7 +1115,7 @@ function tearing_schedule!(state::TransformationState, ci::CodeInstance, key::To
11131115 curval = nonlinearssa
11141116 (curval, thiscoeff) = schedule_incidence! (compact1, curval, incT, var, line, settings; vars= var_sols, schedule_missing_var!)
11151117 @assert isa (thiscoeff, Float64)
1116- curval = ir_mul_const! (compact1, line, settings, 1 / thiscoeff, curval)
1118+ curval = ir_mul_const! (compact1, line, settings, 1 / thiscoeff, curval, @__SOURCE__ )
11171119 var_sols[var] = isa (curval, SSAValue) ? CarriedSSAValue (ordinal, curval. id) : curval
11181120 insert_solved_var_here! (compact1, var, curval, line)
11191121 else
0 commit comments